Hello android

679 views
628 views

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
679
On SlideShare
0
From Embeds
0
Number of Embeds
86
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Hello android

  1. 1. OSLLHello Android Vasily Romanikhin 1 vasily.romanikhin@gmail.com  
  2. 2. Table of content● About Android● Android Architecture● Application Fundamentals ● Activity, Service,  ContentProvider,  BroadcastReceiver, Intent classes ● Application Resources● User Interface● Software for developing● Practice   2
  3. 3. What is Android? ● Android Inc. ● Open Handset Alliance  (OHA) ● September 23, 2008 ● October 21, 2008   3
  4. 4. Android Architecture   4
  5. 5. The project structureMyProject/ ✔ src/ src/ MyActivity.java ✔ res/ res/ drawable/ ✔ drawable/ icon.png ✔ layout/ layout/ main.xml ✔ values/ values/ strings.xml ✔ gen/ raw/ libs/ ✔ AndroidManifest.xml ... assets/ ... gen/ R.java 5 AndroidManifest.xml  
  6. 6. Application Fundamentals● Application Components: ● Activities ● Services ● Broadcast receivers ● Content providers● ~ Intent   6
  7. 7. Activityhttp://developer.android.com/reference/android/app/Activity.html ●      protected void  onCreate(Bundle  savedInstanceState); ●      protected void onStart(); ●      protected void  onRestart(); ●      protected void  onResume(); ●      protected void  onPause(); ●      protected void onStop(); ●      protected void  onDestroy();   7
  8. 8. Servicehttp://developer.android.com/reference/android/app/Service.html ● startService(...) ● stopService(...) ● bindService(...) ● unbindService(...)   8
  9. 9. Service Implementationexample   9
  10. 10. BroadcastReceiverhttp://developer.android.com/reference/android/content/BroadcastReceiver.html● public void onReceive(Context context,  Intent intent) {/* Actions … */}● Before using BR you should register it  (dynamically – in code; or statically –  in AndroidManifest.xml)● The most often used with Service   10
  11. 11. ContentProviderhttp://developer.android.com/reference/android/content/ContentProvider.html The primary methods that need to be implemented are:● onCreate() which is called to initialize the provider● query(Uri, String[], String, String[], String) which returns data to the  caller● insert(Uri, ContentValues) which inserts new data into the content  provider● update(Uri, ContentValues, String, String[]) which updates existing data  in the content provider● delete(Uri, String, String[]) which deletes data from the content  provider ● Why is it need? ● See also ContentResolver, SQLiteOpenHanhler, SQLiteDatabase, SQLiteQueryBuilder, Cursor, ManagedCursor.   11
  12. 12. Process Lifecycle Foreground process Critical Priority Visible process High Priority Service process Background process Low Priority Empty process   12
  13. 13. AndroidManifest.xmlhttp://developer.android.com/guide/topics/manifest/manifest-intro.html <activity> <intent-filter> <action /> <category /><?xml version="1.0" <data />encoding="utf-8"?> </intent-filter><manifest> <meta-data /> <uses-permission /> </activity> <permission /> <activity-alias> <permission-tree /> <intent-filter>...</intent-filter> <permission-group /> <meta-data /> <uses-sdk /> </activity-alias> <uses-configuration /> <service> <uses-feature /> <intent-filter>...</intent-filter> <supports-screens /> <meta-data/> <compatible-screens /> </service> <supports-gl-texture /> <receiver> <application> <intent-filter>...</intent-filter> ... <meta-data /> </application> </receiver></manifest> <provider> <grant-uri-permission /> <meta-data /> </provider>   13
  14. 14. Application Resourses res/MyProject/ ● anim/ src/ MyActivity.java ● color/ res/ drawable/ ● drawable/ icon.png layout/ ● layout/ main.xml values/ ● menu/ strings.xml raw/ ● values/ gen/ R.java ● xml/   ● raw 14
  15. 15. Application Resourcesres/ drawable/ icon.png background.png drawable-hdpi/ icon.png background.png   15
  16. 16. Accessing Resources/res/values/strings.xml   16
  17. 17. User Interface● Runtime (programmically)● Xml layout file (ex: res/layout/main.xml)● ViewGroup● View   17
  18. 18. Example layout file   18
  19. 19. DDMSDDMS (Dalvik Debug Monitoring Service) provides: ● thread and heap information on the device● logcat● process● radio state information● incoming call and SMS spoofing ● location data spoofing● screen capture on the device and more.   19
  20. 20. Application Testing TestCase JUnit Project Test Project AndroidTestCase tested.project.dir=./.. ServiceTestCase ProviderTestCase2adb shell monkey ­p  ru.spb.osll.fileman ApplicationTestCase ager ­v 500   20
  21. 21. Required software● JDK  >= 1.5 ● Android SDK  (http://developer.android.com/sdk/index.html) ● Adding Platforms and Other Components● Android NDK (http://developer.android.com/sdk/ndk/index.html)● Ant >= 1.7 Eclipse (http://www.eclipse.org/downloads/) ADT (http://developer.android.com/sdk/eclipse­adt.html)   21
  22. 22. Adding Platforms and OtherComponents● android­sdk<...>/tools/android (Linux or Mac)● SDK Manager.exe (Windows) Result: ● AVDs ● USB Drivers ● ...   22
  23. 23. Troubles● Problems with jdk (dont use open­jdk)● ia32­libs (apt­get install ia32­libs)● Developing on a Device ● USB Vendor IDs (for Linux or Mac)     Device ???? ● USB Driver (for Windows)   23
  24. 24. Practice● ExampleButton● ExampleButtonExt● ExStackActivity● ExService● ExBroadcastReceiver   24
  25. 25. What is remained...● Storage data  ● Internal, External Storage ● DB ● SharedPreferences● Designing for Performance    25
  26. 26. ● Questions... ??? ● Thanks!   26

×