Содержание
- 2. ANDROID HISTORY Android is an open source and Linux-based Operating System for mobile devices such as
- 4. REQUIRED TOOLS Java JDK5 or later version Java Runtime Environment (JRE) 6 Android SDK Android Studio
- 6. PROJECT FOLDERS src - This contains the .java source files for your project. By default, it
- 7. ACTIVITIES An activity represents a single screen with a user interface, in-short Activity performs actions on
- 9. LAYOUT android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" > android:layout_width="wrap_content“ android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:text="@string/hello_world"/>
- 10. MANIFEST package="com.example.helloworld" android:versionCode="1" android:versionName="1.0" > android:minSdkVersion="8" android:targetSdkVersion="22" /> android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > android:name=".MainActivity“ android:label="@string/title_activity_main" >
- 11. BUILDING WITH GRADLE apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "com.resentient.hwat"
- 13. PASSING DATA BETWEEN ACTIVITIES Ways to pass data between activities: Save the data in a database
- 14. SHARED PREFERENCES Shared Preferences allow you to save and retrieve data in the form of key-value
- 15. INTENT An Intent in the Android operating system is a software mechanism that allows users to
- 16. Starting camera example: Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Uril file = Uri.fromFile(new File(pathToImage)); intent.putExtra(MediaStore.EXTRA_OUTPUT, file); startActivityForResult(intent,
- 17. Sharing in facebook example: public void shareOnFacebook(View view) { Uri uri = Uri.fromFile(takeScreenshot()); Intent sharingIntent =
- 18. GET VIEW ELEMENTS FROM ACTIVITY ImageView takenPhoto = (ImageView) findViewById(R.id.imageView); takenPhoto.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.correct)); takenPhoto.setVisibility(View.INVISIBLE);
- 19. ADDING LISTENERS TO ELEMENTS final Button button = (Button) findViewById(R.id.button_id); button.setOnClickListener(new View.OnClickListener() { @Override public void
- 20. ON TOUCH AND SWIPE EVENTS @Override public boolean onTouchEvent(MotionEvent event) { int action = event.getActionMasked(); switch
- 21. case MotionEvent.ACTION_UP: float finalX = event.getX(); float finalY = event.getY(); Log.d(TAG, "Action was UP"); if (initialX
- 22. DIALOG WINDOWS final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.share_dialog); dialog.setCanceledOnTouchOutside(true); dialog.show();
- 23. CHECK INTERNET CONNECTION ConnectivityManager connectivity = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE); if (connectivity != null) { NetworkInfo info =
- 24. ASYNC TASK class DataLoader extends AsyncTask { @Override protected Void doInBackground(Void... params) { insertLevelsDataIntoDatabase(); return null;
- 25. SQLITE Creating database: public class DatabaseCreator extends SQLiteOpenHelper { public DatabaseCreator(Context context) { super(context, “MyDatabase”, null,
- 26. Inserting data into database: DatabaseCreator dbHelper = new DatabaseCreator(context); SQLiteDatabase db = dbHelper.getWritableDatabase(); ContentValues cv =
- 27. Fetching data from database: DatabaseCreator dbHelper = new DatabaseCreator(context); SQLiteDatabase db = dbHelper.getWritableDatabase(); Cursor cursor =
- 29. Скачать презентацию