Presentation is loading. Please wait.

Presentation is loading. Please wait.

lec 05 Admin stuff; schedule IOS versus Android Preferences

Similar presentations


Presentation on theme: "lec 05 Admin stuff; schedule IOS versus Android Preferences"— Presentation transcript:

1 lec 05 Admin stuff; schedule IOS versus Android Preferences
Configuration Changes Advanced UI 1

2 You can persist data in several ways :
Preferences: key/value pairs SQLite: Use a very small RDBMS that is sandboxed to your app and then expose it to other apps using a content provider Files: You can read/write files to your raw directory-- avoid this. Network: store data on the internet and read/write using any available Internet protocol – avoid this.

3 You must declare an object called SharedPreferences
SharedPreferences shp; Assign it like so: shp = PreferenceManager.getDefaultSharedPreferences(this); Access elements like so: String strName = shp.getString("name_key", ""); Put elements like so: SharedPreferences.Editor sheEditor = shp.edit(); sheEditor.putString("name", "Rumpelstilskin"); sheEditor.commit();

4

5 Configuration Changes aka rotate screen
To force rotate a screen in emulator, press cntrl-F12 (on PC)

6

7 Usually you restore your state in onCreate
Usually you restore your state in onCreate. It is possible to restore it in onRestoreInstanceState as well, but not very common. (onRestoreInstanceState is called after onStart, whereas onCreate is called before onStart. Use the put methods to store values in onSaveInstanceState: protected void onSaveInstanceState(Bundle icicle) { icicle.putLong("param", value); super.onSaveInstanceState(outState); } And restore the values in onCreate: public void onCreate(Bundle icicle) { if (icicle != null){ value = icicle.getLong("param");

8

9 Student presentations:
A: AsyncTask: How to get/parse JSON data (weather data) from RESTful web service (with recipe) B: MediaStore: Taking pictures and videos and storing them for use in an app (not the standard gallery) (with recipe) C: Voice Recognition: How to use voice recognition inside an app (with recipe) D: Tracking locations (using GPS) for a jog or a race. Data capture so that I can map where I went and how far I traveled, avg speed (with recipe) Activies, Receivers, Services, and Content-Providers all must be declared in the manifest. Intnets are calls to the op-system. It handles all intents, explicit and implicit.


Download ppt "lec 05 Admin stuff; schedule IOS versus Android Preferences"

Similar presentations


Ads by Google