Android Froyo

2,482 views

Published on

30 min developer crash on new features in Froyo

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,482
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
41
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Android Froyo

  1. 1. Android 2.2 Froyo Robert Cooper
  2. 2. User Features  Better BlueTooth support  Better Exchange support  Improved Camera app  Better Music app  Tethering
  3. 3. Infrastructure  Dalvik JIT (awesome sauce)  V8 in the Browser  Support for > 256MB RAM  SDIO improvements
  4. 4. Stuff You Care About  Apps on External Storage  Data Backup  Device Policy Manager  Cloud to Device Messaging  New UI Goodness  Car Mode  Night Mode
  5. 5. Stuff You Care About  New Search Support  Camera Preview (Now ~20 FPS)  OpenGL ES 2.0  Improved Media Framework/OpenCore  Crash and Hang Reports on the Market
  6. 6. Apps on External Storage  New Compiler Framework? This used to not work... <uses-sdkandroid:minSdkVersion="4" /> With Platform compiler set in Eclipse
  7. 7. Apps on External Storage <manifest xmlns:android="http://schemas.android.c om/apk/res/android” package="com.totsp.crossword.shortyz” android:installLocation="preferExternal "> android:installLocation can be “preferExternal” or “auto”
  8. 8. Apps on External Storage Doesn’t work when you have a …  Service  Input Method Engine  Widget or Live Folder  Live Wallpaper  Account Manager or Sync Adapter  Device Administration Receiver
  9. 9. Data Backup  Attaches Data to your users Android Market profile (Or other… OEM, Carrier, Whatever)  Data follows the user across devices or wipes
  10. 10. Data Backup BackupAgent: <application android:icon="@drawable/icon” android:label="@string/app_name” android:backupAgent= "com.totsp.crossword.BackupAgent” android:restoreAnyVersion="true">
  11. 11. Backup Agent  You can implement BackupAgent yourself  Triggers onBackup() and onRestore() on the BackupAgent interface  Gives you BackupDataOutput and BackupDataInput classes  You can use these to write arbitrary binary data to a keyed data set
  12. 12. Data Backup Well gee whiz Wally, that seems like a lot of work…
  13. 13. Data Backup BackupAgentHelper  Allows you to compose multiple helpers to backup your data  Easy backup for SharedPrefs and Files  Databases?
  14. 14. Data Backup public class BackupAgent extends BackupAgentHelper { static final String PREFS = "user_preferences”; static final String PREFS_BACKUP_KEY = "prefs”; public void onCreate() { SharedPreferencesBackupHelper helper = new SharedPreferencesBackupHelper(this, PREFS); addHelper(PREFS_BACKUP_KEY, helper); } }
  15. 15. Data Backup public class MyFileBackupAgent extends BackupAgentHelper { static final String TOP_SCORES = "scores”; static final String PLAYER_STATS = "stats”; static final String FILES_BACKUP_KEY = "myfiles”; void onCreate() { FileBackupHelper helper = new FileBackupHelper(this, TOP_SCORES, PLAYER_STATS); addHelper(FILES_BACKUP_KEY, helper); } }
  16. 16. Device Policy Manager <receiver android:name=".app.DeviceAdminSample” android:label="@string/sample_device_admin” android:description= "@string/sample_device_admin_description” android:permission= "android.permission.BIND_DEVICE_ADMIN"> <meta-data android:name="android.app.device_admin” android:resource="@xml/device_admin" /> <intent-filter> <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /> </intent-filter> </receiver>
  17. 17. Device Policy Manager <device-admin> <uses-policies> <limit-password /> <watch-login /> <reset-password /> <force-lock /> <wipe-data /> </uses-policies> </device-admin>
  18. 18. Device Policy Manager DON’T DO THIS! public void onPasswordFailed(Context context, Intent intent) { this.getManager(context).wipeData(0); }
  19. 19. Cloud to Device Messaging  Pass a K-V Pair data object to device (Intent extras)  Sent from your server, to Google  Addressed with user’s device reg id and application package name
  20. 20. Cloud to Device Messaging On the device… <permission android:name="com.totsp.crossword.shortyz.C2D _MESSAGE” android:protectionLevel="signature" /> <uses-permission android:name="com.totsp.crossword.shortyz.C2D _MESSAGE" /> <uses-permission android:name="com.google.android.c2dm.permiss ion.RECEIVE" />
  21. 21. Cloud to Device Messaging <receiver android:name=".PushReceiver” android:permission="com.google.android.c2dm.permission.SEN D”> <intent-filter> <action android:name="com.google.android.c2dm.intent.RECEIVE" /> <category android:name="com.totsp.crossword.shortyz" /> </intent-filter> <intent-filter> <action android:name="com.google.android.c2dm.intent.REGISTRATION" /><category android:name="com.totsp.crossword.shortyz" /> </intent-filter> </receiver>
  22. 22. Cloud to Device Messaging Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGI STER"); registrationIntent.putExtra(”app", PendingInt ent.getBroadcast(this, 0, new Intent(), 0); registrationIntent.putExtra("sender”,”shortyz -noreply@kebernet.net”); startService(registrationIntent);
  23. 23. Cloud to Device Messaging protected void onReceive(Context context, Intent intent) { String base64data = intent.getExtras().getString(PAYLOAD); ...
  24. 24. Cloud to Device Messaging Sending Messages from the Server Step 1: Post message to https://android.apis.google.com/c2dm/send
  25. 25. Cloud to Device Messaging Post Fields  registration_id : Reg id from the phone  collapse_key : A key used to prune dupes/clobbers when the phone is offline  data.[some name]: Data to push to the intent  delay_while_idle: Don’t push if the phone is idle  Authorization header for the sender
  26. 26. Cloud to Device Messaging Hard Parts:  One Way – no Device to Cloud Messaging  Juggling Registration IDs in your app and from the phone  Device registers, gets a reg ID  posts it back to your app with your apps user creds, etc  Where is my Google Wave “State” object for this?
  27. 27. UiModeManager  Lets you change the display mode or alter your display based on the current mode UiModeManager mgr = (UiModeManager) getSystemService(UI_MODE_SERVICE); mgr.setNightMode(UiModeManager.MODE_NIGHT_YES ); // ---- if(mgr.getCurrentModeType() == Configuration.UI_MODE_TYPE_DESK) {
  28. 28. Lots More http://developer.android.com

×