Android Application Model II. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.
|
|
- Ruth Myra Harrison
- 6 years ago
- Views:
Transcription
1 Android Application Model II CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1
2 Outline Activity Lifecycle Services Persistence Content Providers 2
3 Recap Android Framework Activities General UI: Layouts, Handler methods Widgets, Custom UI classes, Handling within the activity Specialized UIs: Menus and the Action Bar Special Activities Preferences UI for larger screens: Fragments 3
4 The Activity Lifecycle Activities are managed by the Android runtime Activities have a lifecycle consisting of states From creation till death Standard (lifecycle) methods on the activity are invoked at each state change (can test by rotating device) 4
5 Activity States Created: Born to run Active: Working 9 to 5 Paused: I m about to break Resumed: Back to work Stopped: Obscured by clouds, vulnerable 5
6 Activity Transitions Created Active Active Paused Paused Stopped Active Stopped Killed 6
7 Timing of Activity Lifecycle Methods 7
8 Lifecycle Methods oncreate(bundle savedinstancestate): create views, (re) initialize state onstart(): Restore transient state or other one-time processing onresume(): Session-specific processing, restore transient state onpause(): Save persistent data, release resources, quickly! Last method guaranteed to be called. onstop(): Called optionally by runtime ondestroy(): If finish() is called, or object is being temporarily destroyed. Use isfinishing() to distinguish. 8
9 Transient State Management Methods onsaveinstancestate(...): Called before onpause(). Use to save transient state. onrestoreinstancestate(...): Called after onstart() and onresume(). Use to restore state. 9
10 Transient State Management: Java // MapsActivity.java public class MapsActivity extends AppCompatActivity... {... private MapView mmapview; private String whereamistring = protected void onsaveinstancestate(bundle outstate) { super.onsaveinstancestate(outstate); mmapview.onsaveinstancestate(outstate); if (whereamistring!= null) outstate.putstring(where_am_i_string, whereamistring);... protected void onrestoreinstancestate(bundle savedinstancestate) { super.onrestoreinstancestate(savedinstancestate); whereamistring = savedinstancestate.getstring(where_am_i_string); if (whereamistring!= null) meditlocation.settext(whereamistring); 10
11 Interaction Across Activities Activity 1: onpause() Activity 2: oncreate(), onstart(), onresume() Activity 1: onstop() if it is obscured 11
12 Starting Activities: Intents and Intent Filters Message posted to the Android runtime to launch an activity. Matched against IntentFilter of activity in AndroidManifest.xml file. Encourages activity reuse among applications Uniform mechanism for launching internal and external activities Allows loose coupling between caller and responder 12
13 Intent and Intent Filter Components Target fully qualified name (string), direct reference Action standard or custom (string) Data (URI) Category of the target object 13
14 Intent Filters: Examples <!-- AndroidManifest.xml --> <intent-filter> <!== for SplashScreen activity ==> <action android:name="android.intent.action.main"/> <category android:name="android.intent.category.launcher"/> </intent-filter> <intent-filter> <!== for Login activity ==> <action android:name="com.wiley.fordummies.androidsdk.tictactoe.login"> <category android:name="android.intent.category.default" /> </intent-filter> 14
15 Intent Invocations: Examples: Java Matching component name: startactivity(new Intent( "com.wiley.fordummies.androidsdk.tictactoe.login")); Direct invocation: startactivity(new Intent(getActivity().getApplicationContext(), SettingsActivity.class)); Passing data: public void sendscoresvia () { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.putextra(android.content.intent.extra_subject, "Look at my AWESOME TicTacToe Score!"); intent.settype("plain/text"); intent.putextra(android.content.intent.extra_text, firstplayername + " score is " + scoreplayerone + " and " + secondplayername + " score is " + scoreplayertwo); 15 startactivity( intent);
16 Intent Invocations: Examples: Kotlin Matching component name: startactivity(intent( "com.wiley.fordummies.androidsdk.tictactoe.login")) Direct invocation: startactivity(intent(activity.applicationcontext, SettingsActivity::class.java)) Passing data: fun sendscoresvia () { val intent = Intent(Intent.ACTION_SEND) intent.putextra(intent.extra_subject, "Look at my AWESOME TicTacToe Score!") intent.type = "plain/text" intent.putextra(intent.extra_text, mfirstplayername + " score is " + mscoreplayerone + " and " + msecondplayername + " score is " + mscoreplayertwo) startactivity( intent) 16
17 Tasks and Activity Stacks Task: a (conceptual) container for sets of likeminded activities Roughly corresponds to a Linux process Activities are stacked in tasks Activities can move across tasks Task is requested by calling intent or selected based on taskaffinity attribute in AndroidManifest.xml file 17
18 Outline Activity Lifecycle Services Persistence Content Providers 18
19 Services Activities for background, long-term processing , music, synchronization Local: Accessible by a single application. Remote (aka bound): Accessible by all applications on the device See: services.html#creatingboundservice Comparison with threads: For coarser-grained processing Lifecycle separated from launching activity More resources consumed More respected J by OS 19
20 Service Example: Java public class MediaPlaybackService extends Service { MediaPlayer public IBinder onbind(intent intent) {... public void oncreate() { player = MediaPlayer.create(this, R.raw.sampleaudio); player.setlooping(true);... public int onstartcommand(intent intent, int flags, int startid) {... Bundle extras = intent.getextras(); String audiofileuristring = extras.getstring("uristring"); Uri audiofileuri = Uri.parse(audioFileURIString); player.reset(); player.setdatasource(this.getapplicationcontext(), audiofileuri); player.prepare(); player.start(); public void ondestroy() { player.stop(); 20
21 Service Example: Kotlin class MediaPlaybackService : Service() {... override fun onbind(intent: Intent): IBinder? {... override fun oncreate() { player = MediaPlayer.create(this, R.raw.sample_audio) player.apply { islooping = true override fun onstartcommand(intent: Intent, flags: Int, startid: Int): Int { super.onstartcommand(intent, flags, startid) val extras = intent.extras if (extras!= null) { val audiofileuristring = extras.getstring("uristring") val audiofileuri = Uri.parse(audioFileURIString) Log.d(TAG, "URI = " + audiofileuri.tostring())... player.reset() player.setdatasource(this.applicationcontext, audiofileuri) player.prepare() player.start() override fun ondestroy() {player.stop() 21
22 Service Invocation Java... Intent musicintent = new Intent( getapplicationcontext(), MyPlaybackService.class); musicintent.putextra( "URIString", maudiofileuri.tostring()); getactivity(). startservice(musicintent);... Kotlin... val musicintent = Intent( activity.applicationcontext, MediaPlaybackService:: class.java) musicintent.putextra( "URIString", maudiofileuri.tostring()) activity.startservice( musicintent)... 22
23 Outline Activity Lifecycle Services Persistence Content Providers 23
24 Saving Persistent Data Files Same as in any Java or Kotlin app Internal storage (Linux file system) Local to app Destroyed upon uninstall External storage (e.g., SD card) Stored to SD card or flash memory (device-dependent) Shared among applications E.g.: Java File imagefile = new File(imageFilePath); Kotlin val imagefile = File(imageFilePath) 24
25 Saving Persistent Data SQLite Sqlite.org: Most widely deployed SQL database engine in the world J Lightweight, transactional Helper class for database creation Methods for operating on SQL statements: Creating a statement Binding data Executing 25
26 SQLite Example: Account Model Class Java // Account.java public class Account { private String mname, mpassword; public Account(String name, String password) {mname = name; mpassword = password; public String getname() {... public String getpassword() public boolean equals(object o) {... Kotlin // Account.kt data class Account(val name: String, val password: String) { // We don't need anything here! Kotlin data classes automatically generate getters, setters, equals(), hashcode(), and public int hashcode() {... // tostring() 26
27 SQLite Example: Database Schema: Java // AccountDbSchema.java public class AccountDbSchema { public static final class AccountsTable { public static final String NAME = "accounts"; public static final class Cols { public static final String NAME = "name"; public static final String PASSWORD = "password"; // Also used with Kotlin 27
28 SQLite Example: Account CursorWrapper Java // AccountCursorWrapper.java public class AccountCursorWrapper extends CursorWrapper { public AccountCursorWrapper( Cursor cursor) { super(cursor); public Account getaccount() { String name = getstring( getcolumnindex(accountstable.cols. NAME)); String password = getstring( getcolumnindex(accountstable.cols. PASSWORD)); Kotlin // AccountCursorWrapper.kt class AccountCursorWrapper(cursor: Cursor) : CursorWrapper(cursor) { val account: Account get() { val name = getstring( getcolumnindex(accountstable.cols. NAME)) val password = getstring( getcolumnindex(accountstable.cols. PASSWORD)) Account account = new Account(name, password); return account; return Account(name, password) 28
29 SQLite Example: Account Singleton: Java // AccountSingleton.java public class AccountSingleton { private static AccountSingleton saccount; private AccountDbHelper mdbhelper; private SQLiteDatabase mdatabase; private static final String INSERT_STMT = "INSERT INTO " + AccountsTable.NAME + "(name, password) VALUES (?,?)" ;... private AccountSingleton(Context context) { mdbhelper = new AccountDbHelper( context.getapplicationcontext()); mdatabase = mdbhelper.getwritabledatabase(); private static ContentValues getcontentvalues( Account account) { ContentValues values = new ContentValues(); values.put(accountstable.cols.name, account.getname()); values.put(accountstable.cols.password, account.getpassword()); return values; // Continued... // Continued... public void addaccount(account account) { ContentValues contentvalues = getcontentvalues(account);... SQLiteStatement statement = mdatabase.compilestatement(insert_stmt); statement.bindstring(1, account.getname()); statement.bindstring(2, account.getpassword()); statement.executeinsert(); public void deleteallaccounts() {... mdatabase.delete(accountstable.name, null, null);... // Also used with Kotlin 29
30 SQLite Example: Helper Class: Java // AccountDbHelper.java public class AccountDbHelper extends SQLiteOpenHelper { private Context mcontext; private static final String DATABASE_NAME = "TicTacToe.db"; private static final int DATABASE_VERSION = 1; public AccountDbHelper(Context context) { super(context, DATABASE_NAME, null, public void oncreate(sqlitedatabase sqlitedatabase) { sqlitedatabase.execsql("create TABLE " + AccountsTable.NAME + "(" + "_id INTEGER PRIMARY KEY AUTOINCREMENT, " + AccountsTable.Cols.NAME + " TEXT, " + AccountsTable.Cols.PASSWORD + " TEXT" + public void onupgrade(sqlitedatabase sqlitedatabase, int oldversion, int newversion) { Log.w("Example", "Example: upgrading DB; dropping/recreating tables."); sqlitedatabase.execsql("drop TABLE IF EXISTS " + AccountsTable.NAME); oncreate(sqlitedatabase); 30
31 SQLite Example: Helper Class: Kotlin // AccountDbHelper.kt class AccountDbHelper(context: Context) : SQLiteOpenHelper( context, DATABASE_NAME, null, DATABASE_VERSION) { private lateinit var mcontext: Context... override fun oncreate(sqlitedatabase: SQLiteDatabase) { sqlitedatabase.execsql("create TABLE " + AccountsTable.NAME + "(" + "_id INTEGER PRIMARY KEY AUTOINCREMENT, " + AccountsTable.Cols.NAME + " TEXT, " + AccountsTable.Cols.PASSWORD + " TEXT" + ")") override fun onupgrade(database: SQLiteDatabase, oldversion: Int, newversion: Int) { Log.w("Example", Upgrading DB; dropping/recreating tables.") database.execsql("drop TABLE IF EXISTS " + AccountsTable.NAME) oncreate(database) companion object { private val DATABASE_NAME = "TicTacToe.db" private val DATABASE_VERSION = 1 31
32 SQLite Example: Database Operations: Java // AccountFragment.java private void createaccount() { String username = metusername.gettext().tostring(); String password = metpassword.gettext().tostring(); String confirm = metconfirm.gettext().tostring(); if ((password.equals(confirm)) && (!username.equals("")) && (!password.equals("")) && (!confirm.equals(""))) { AccountSingleton singleton = AccountSingleton.get(getActivity().getApplicationContext()); Account account = new Account(username, password); singleton.addaccount(account); Toast.makeText(getActivity().getApplicationContext(), "New record inserted", Toast.LENGTH_SHORT).show(); else if ((username.equals("")) (password.equals("")) (confirm.equals(""))) { Toast.makeText(getActivity().getApplicationContext(), "Missing entry", Toast.LENGTH_SHORT).show(); else if (!password.equals(confirm)) { FragmentManager manager = getfragmentmanager(); AccountErrorDialogFragment fragment = new AccountErrorDialogFragment(); fragment.show(manager, "account_error"); else { Log.e(TAG, "An unknown account creation error occurred."); 32
33 SQLite Example: Database Operations: Kotlin // AccountFragment.kt private fun createaccount() { //this.output = (TextView) this.findviewbyid(r.id.out_text); val username = metusername.text.tostring() val password = metpassword.text.tostring() val confirm = metconfirm.text.tostring() if (password == confirm && username!= "" && password!= "" && confirm!= "") { val singleton = AccountSingleton.get(activity.applicationContext) val account = Account(username, password) singleton.addaccount(account) Toast.makeText(activity.applicationContext, "New record inserted", Toast.LENGTH_SHORT).show() else if (username == "" password == "" confirm == "") { Toast.makeText(activity.applicationContext, "Missing entry", Toast.LENGTH_SHORT).show() else if (password!= confirm) { val manager = fragmentmanager val fragment = AccountErrorDialogFragment() fragment.show(manager, "account_error") else { Log.e(TAG, "An unknown account creation error occurred.") 33
34 Outline Activity Lifecycle Services Persistence Content Providers 34
35 Sharing Content Content Providers Standard content providers: Contacts, dictionary, media Referred to by URI prefix: content:// Standard providers Permission must be requested in manifest: <uses-permission android:name= "android.permission.read_contacts"/> Android 6+: permission for dangerous actions must be requested at runtime ( training/permissions/requesting.html ) ListView of user s contacts 35
36 Content Provider Example: Java (1) // ContentsFragment.java public class ContactsFragment extends Fragment implements LoaderManager.LoaderCallbacks<Cursor> { private ListView mcontactslistview; private static final String[] PROJECTION = { ContactsContract.Contacts._ID, ContactsContract.Contacts.LOOKUP_KEY, ContactsContract.Contacts.DISPLAY_NAME_PRIMARY ; private final static String[] FROM_COLUMNS = { ContactsContract.Contacts.DISPLAY_NAME_PRIMARY ; private final static int[] TO_IDS = { R.id.contact_info public void onactivitycreated(...) {... mcontactslistview = (ListView) getactivity().findviewbyid(r.id.contact_list_view); requestcontacts(); private void requestcontacts() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!hasreadcontactpermission()) { requestpermissions(new String[]{Manifest.permission.READ_CONTACTS, PERMISSION_REQUEST_READ_CONTACTS); else { showcontacts(); else { showcontacts(); 36
37 Content Provider Example: Java (2) // ContactsFragment.java, continued... private boolean hasreadcontactpermission() { return getactivity().checkselfpermission(manifest.permission.read_contacts) == public void onrequestpermissionsresult(... ) { if (requestcode == PERMISSION_REQUEST_READ_CONTACTS) { if (grantresults[0] == PackageManager.PERMISSION_GRANTED) { showcontacts(); else { // Show error message private void showcontacts() { // Gets a CursorAdapter mcursoradapter = new SimpleCursorAdapter(getActivity(), R.layout.list_item_contact, null, FROM_COLUMNS, TO_IDS, 0); // Sets the adapter for the ListView mcontactslistview.setadapter(mcursoradapter); // Initializes the loader, which loads the contacts asynchronously getloadermanager().initloader(0, null, this); 37
38 Content Provider Example: Java (3) // ContactsFragment.java, public Loader<Cursor> oncreateloader(int id, Bundle args) { return new CursorLoader(getActivity(), ContactsContract.Contacts.CONTENT_URI, PROJECTION, null, null, ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC" public void onloadfinished(loader<cursor> loader, Cursor data) { // Put the result Cursor in the adapter for the ListView public void onloaderreset(loader<cursor> loader) { mcursoradapter.swapcursor(null); // End of Fragment 38
39 Content Provider Example: Kotlin (1) // ContactsFragment.kt class ContactsFragment : Fragment(), LoaderManager.LoaderCallbacks<Cursor> { private lateinit var mcontactslistview: ListView companion object {... private val PROJECTION = arrayof(contactscontract.contacts._id, ContactsContract.Contacts.LOOKUP_KEY, ContactsContract.Contacts.DISPLAY_NAME_PRIMARY) private val PERMISSION_REQUEST_READ_CONTACTS = 1 private val FROM_COLUMNS = arrayof(contactscontract.contacts.display_name_primary) private val TO_IDS = intarrayof(r.id.contact_info) private var mcursoradapter: SimpleCursorAdapter? = null override fun onactivitycreated(savedinstancestate: Bundle?) {... mcontactslistview = activity.findviewbyid<listview>(r.id.contact_list_view) requestcontacts() private fun requestcontacts() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!hasreadcontactpermission()) { requestpermissions( arrayof(manifest.permission.read_contacts), PERMISSION_REQUEST_READ_CONTACTS) else { showcontacts() else { showcontacts() 39
40 Content Provider Example: Kotlin (2) // ContactsFragment.kt, continued... private fun hasreadcontactpermission(): Boolean { return activity.checkselfpermission(manifest.permission.read_contacts) == PackageManager.PERMISSION_GRANTED override fun onrequestpermissionsresult(... ) { if (requestcode == PERMISSION_REQUEST_READ_CONTACTS) { if (grantresults[0] == PackageManager.PERMISSION_GRANTED) {showcontacts() else { // Show error message private fun showcontacts() { // Gets a CursorAdapter mcursoradapter = SimpleCursorAdapter(activity, R.layout.list_item_contact, null, FROM_COLUMNS, TO_IDS, 0) // Sets the adapter for the ListView mcontactslistview.adapter = mcursoradapter // Initializes the loader loadermanager.initloader(0, null, this) 40
41 Content Provider Example: Kotlin (3) // ContactsFragment.kt, continued... override fun oncreateloader(id: Int, args: Bundle): Loader<Cursor> { return CursorLoader(activity, ContactsContract.Contacts.CONTENT_URI, PROJECTION, null, null, ContactsContract.Contacts.DISPLAY_NAME + " COLLATE LOCALIZED ASC") override fun onloadfinished(loader: Loader<Cursor>, data: Cursor) { // Put the result Cursor in the adapter for the ListView mcursoradapter!!.swapcursor(data) override fun onloaderreset(loader: Loader<Cursor>) { mcursoradapter!!.swapcursor(null) // End of class definition 41
42 Even More?! Yes! More widgets, styles and themes Maps , media, telephony Sensors 42
43 Summary Activities: One screen of content that user sees Can be paused, resumed by users Managing Activity lifecycle is crucial Services: Long-running tasks Persistence: Files (on SD card) SQLite database Look at Content Providers: mechanism for sharing data 43
Internal Services. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.
Internal Services CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Internal Services Communication: Email, SMS and telephony Audio and
More informationUnderstand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml
Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good
More informationMinds-on: Android. Session 2
Minds-on: Android Session 2 Paulo Baltarejo Sousa Instituto Superior de Engenharia do Porto 2016 Outline Activities UI Events Intents Practice Assignment 1 / 33 2 / 33 Activities Activity An activity provides
More informationAndroid Application Model I
Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);
More informationACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi
ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi Introduction An application is composed of at least one Activity GUI It is a software component that stays behind a GUI (screen) Activity It runs inside the
More informationAndroid Activities. Akhilesh Tyagi
Android Activities Akhilesh Tyagi Apps, memory, and storage storage: Your device has apps and files installed andstoredonitsinternaldisk,sdcard,etc. Settings Storage memory: Some subset of apps might be
More informationUnderstanding Application
Introduction to Android Application Development, Android Essentials, Fifth Edition Chapter 4 Understanding Application Components Chapter 4 Overview Master important terminology Learn what the application
More informationAndroid Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.
Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities
More informationSQLite Database. References. Overview. Structured Databases
SQLite Database References Android Developers Article https://developer.android.com/training/basics/data-storage/databases.html Android SQLite Package Reference https://developer.android.com/reference/android/database/sqlite/package-summary.html
More informationOverview of Activities
d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming
More informationServices. service: A background task used by an app.
CS 193A Services This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Services service: A background task
More informationActivities. https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities
Activities https://developer.android.com/guide/components/activities.html Repo: https://github.com/karlmorris/basicactivities Overview What is an Activity Starting and stopping activities The Back Stack
More informationStates of Activities. Active Pause Stop Inactive
noname Conceptual Parts States of Activities Active Pause Stop Inactive Active state The state that the activity is on the most foreground and having a focus. This is in Active state. Active state The
More informationCS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle
CS378 - Mobile Computing Anatomy of an Android App and the App Lifecycle Application Components five primary components different purposes and different lifecycles Activity single screen with a user interface,
More informationCMSC436: Fall 2013 Week 3 Lab
CMSC436: Fall 2013 Week 3 Lab Objectives: Familiarize yourself with the Activity class, the Activity lifecycle, and the Android reconfiguration process. Create and monitor a simple application to observe
More informationExternal Services. CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion
External Services CSE 5236: Mobile Application Development Course Coordinator: Dr. Rajiv Ramnath Instructor: Adam C. Champion 1 External Services Viewing websites Location- and map-based functionality
More informationAndroid Fundamentals - Part 1
Android Fundamentals - Part 1 Alexander Nelson September 1, 2017 University of Arkansas - Department of Computer Science and Computer Engineering Reminders Projects Project 1 due Wednesday, September 13th
More informationMobile Programming Lecture 10. ContentProviders
Mobile Programming Lecture 10 ContentProviders Lecture 9 Review In creating a bound service, why would you choose to use a Messenger over extending Binder? What are the differences between using GPS provider
More informationDatabase Development In Android Applications
ITU- FAO- DOA- TRCSL Training on Innovation & Application Development for E- Agriculture Database Development In Android Applications 11 th - 15 th December 2017 Peradeniya, Sri Lanka Shahryar Khan & Imran
More informationMOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR
MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM Android Component A Service is an application component that runs in the background, not interacting
More informationActivities and Fragments
Activities and Fragments 21 November 2017 Lecture 5 21 Nov 2017 SE 435: Development in the Android Environment 1 Topics for Today Activities UI Design and handlers Fragments Source: developer.android.com
More informationEng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza. Data persistence
Eng. Jaffer M. El-Agha Android Programing Discussion Islamic University of Gaza Data persistence Shared preferences A method to store primitive data in android as key-value pairs, these saved data will
More informationMobile Computing Practice # 2d Android Applications Local DB
Mobile Computing Practice # 2d Android Applications Local DB In this installment we will add persistent storage to the restaurants application. For that, we will create a database with a table for holding
More informationMobile Programming Lecture 5. Composite Views, Activities, Intents and Filters
Mobile Programming Lecture 5 Composite Views, Activities, Intents and Filters Lecture 4 Review How do you get the value of a string in the strings.xml file? What are the steps to populate a Spinner or
More informationMobile Application Development Android
Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/15/2014
More informationTablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time
Tablets have larger displays than phones do They can support multiple UI panes / user behaviors at the same time The 1 activity 1 thing the user can do heuristic may not make sense for larger devices Application
More informationMobile Computing Fragments
Fragments APM@FEUP 1 Fragments (1) Activities are used to define a full screen interface and its functionality That s right for small screen devices (smartphones) In bigger devices we can have more interface
More informationCS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu
CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu Android Activity LifeCycle Starting Activities Android applications don't start with a call to main(string[])
More informationAndroid permissions Defining and using permissions Component permissions and related APIs
Android permissions Defining and using permissions Component permissions and related APIs Permissions protects resources and data For instance, they limit access to: User information e.g, Contacts Cost-sensitive
More informationAndroid Application Development
Android Application Development Octav Chipara What is Android A free, open source mobile platform A Linux-based, multiprocess, multithreaded OS Android is not a device or a product It s not even limited
More informationEMBEDDED SYSTEMS PROGRAMMING Android Services
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Android Services APP COMPONENTS Activity: a single screen with a user interface Broadcast receiver: responds to system-wide broadcast events. No user interface Service:
More informationCS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu
CS 4518 Mobile and Ubiquitous Computing Lecture 5: Rotating Device, Saving Data, Intents and Fragments Emmanuel Agu Administrivia Moved back deadlines for projects 2, 3 and final project See updated schedule
More informationUNDERSTANDING ACTIVITIES
Activities Activity is a window that contains the user interface of your application. An Android activity is both a unit of user interaction - typically filling the whole screen of an Android mobile device
More informationAn Android Studio SQLite Database Tutorial
An Android Studio SQLite Database Tutorial Previous Table of Contents Next An Android Studio TableLayout and TableRow Tutorial Understanding Android Content Providers in Android Studio Purchase the fully
More informationServices. Marco Ronchetti Università degli Studi di Trento
1 Services Marco Ronchetti Università degli Studi di Trento Service An application component that can perform longrunning operations in the background and does not provide a user interface. So, what s
More informationAndroid. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license
Android Android Mobile operating system developed by Google A complete stack OS, framework A rich set of applications Email, calendar, browser, maps, text messaging, contacts, camera, dialer, music player,
More informationANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Entire Lifetime An activity begins its lifecycle when entering the oncreate() state If not interrupted
More informationANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I)
ANDROID APPS DEVELOPMENT FOR MOBILE AND TABLET DEVICE (LEVEL I) Lecture 3: Android Life Cycle and Permission Android Lifecycle An activity begins its lifecycle when entering the oncreate() state If not
More informationDiving into Android. By Jeroen Tietema. Jeroen Tietema,
Diving into Android By Jeroen Tietema Jeroen Tietema, 2015 1 Requirements 4 Android SDK 1 4 Android Studio (or your IDE / editor of choice) 4 Emulator (Genymotion) or a real device. 1 See https://developer.android.com
More informationApplication Fundamentals
Application Fundamentals CS 2046 Mobile Application Development Fall 2010 Announcements CMS is up If you did not get an email regarding this, see me after class or send me an email. Still working on room
More informationMultiple Activities. Many apps have multiple activities
Intents Lecture 7 Multiple Activities Many apps have multiple activities An activity A can launch another activity B in response to an event The activity A can pass data to B The second activity B can
More informationMobile Application Development Android
Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 -recap Views and Layouts Events Basic application components Activities Intents BroadcastReceivers
More informationMobile Application Development Android
Mobile Application Development Android Lecture 3 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 2 - recap Views and Layouts Events Basic application components Activities Intents 9/22/2017
More informationEMBEDDED SYSTEMS PROGRAMMING Application Basics
EMBEDDED SYSTEMS PROGRAMMING 2015-16 Application Basics APPLICATIONS Application components (e.g., UI elements) are objects instantiated from the platform s frameworks Applications are event driven ( there
More informationContentProvider & ContentResolver ContentResolver methods CursorLoader Implementing ContentProviders
ContentProvider & ContentResolver ContentResolver methods CursorLoader Implementing ContentProviders Represents a repository of structured data Encapsulates data sets Enforces data access permissions Intended
More informationMobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5
1 Mobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5 Prof. Hwansoo Han T.A. Sung-in Hong T.A. Minseop Jeong 2 Background processing Every Android app has a main
More informationCS378 -Mobile Computing. Anatomy of and Android App and the App Lifecycle
CS378 -Mobile Computing Anatomy of and Android App and the App Lifecycle Hello Android Tutorial http://developer.android.com/resources/tutorials/hello-world.html Important Files src/helloandroid.java Activity
More informationMobile and Ubiquitous Computing: Android Programming (part 4)
Mobile and Ubiquitous Computing: Android Programming (part 4) Master studies, Winter 2015/2016 Dr Veljko Pejović Veljko.Pejovic@fri.uni-lj.si Examples from: Mobile and Ubiquitous Computing Jo Vermeulen,
More informationCS371m - Mobile Computing. Content Providers And Content Resolvers
CS371m - Mobile Computing Content Providers And Content Resolvers Content Providers One of the four primary application components: activities content providers / content resolvers services broadcast receivers
More informationAndroid Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ]
s@lm@n Android Exam AND-401 Android Application Development Version: 7.0 [ Total Questions: 129 ] Android AND-401 : Practice Test Question No : 1 Which of the following is required to allow the Android
More informationLecture 2 Android SDK
Lecture 2 Android SDK This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a
More informationChapter 5 Defining the Manifest
Introduction to Android Application Development, Android Essentials, Fifth Edition Chapter 5 Defining the Manifest Chapter 5 Overview Use the Android manifest file for configuring Android applications
More informationCS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu
CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu Fragments Recall: Fragments Sub-components of an Activity (screen) An activity can contain multiple fragments, organized
More informationINTRODUCTION TO ANDROID
INTRODUCTION TO ANDROID 1 Niv Voskoboynik Ben-Gurion University Electrical and Computer Engineering Advanced computer lab 2015 2 Contents Introduction Prior learning Download and install Thread Android
More informationCS 193A. Activity state and preferences
CS 193A Activity state and preferences This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Activity instance
More informationProgramming with Android: Intents. Luca Bedogni. Dipartimento di Scienze dell Informazione Università di Bologna
Programming with Android: Intents Luca Bedogni Dipartimento di Scienze dell Informazione Università di Bologna Outline What is an intent? Intent description Handling Explicit Intents Handling implicit
More informationServices. Background operating component without a visual interface Running in the background indefinitely
Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android runs in background, they don t have an interface
More informationAndroid framework overview Activity lifecycle and states
http://www.android.com/ Android framework overview Activity lifecycle and states Major framework terms 1 All Android apps contains at least one of the 4 components Activity (1) Building block of the UI.
More informationSQLite. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases. What is a Database Server. Advantages of SQLite
SQLite 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 6: Working with Databases Dr Dimitris C. Dracopoulos SQLite is a tiny yet powerful database engine. Besides Android, it can be found in: Apple iphone
More informationFragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment
FRAGMENTS Fragments An activity is a container for views When you have a larger screen device than a phone like a tablet it can look too simple to use phone interface here. Fragments Mini-activities, each
More informationProduced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology
Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie Android Anatomy Android Anatomy 2! Agenda
More informationAndroid Services & Local IPC: Overview of Programming Bound Services
: Overview of Programming Bound Services d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Professor of Computer Science Institute for Software Integrated Systems Vanderbilt University Nashville,
More informationMobile Computing. Introduction to Android
Mobile Computing Introduction to Android Mobile Computing 2011/2012 What is Android? Open-source software stack for mobile devices OS, middleware and key applications Based upon a modified version of the
More informationUI Fragment.
UI Fragment 1 Contents Fragments Overviews Lifecycle of Fragments Creating Fragments Fragment Manager and Transactions Adding Fragment to Activity Fragment-to-Fragment Communication Fragment SubClasses
More informationWriting Efficient Drive Apps for Android. Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations
Writing Efficient Drive Apps for Android Claudio Cherubino / Alain Vongsouvanh Google Drive Developer Relations Raise your hand if you use Google Drive source: "put your hands up!" (CC-BY) Raise the other
More informationLifecycle-Aware Components Live Data ViewModel Room Library
Lifecycle-Aware Components Live Data ViewModel Room Library Multiple entry points launched individually Components started in many different orders Android kills components on reconfiguration / low memory
More informationANDROID SYLLABUS. Advanced Android
Advanced Android 1) Introduction To Mobile Apps I. Why we Need Mobile Apps II. Different Kinds of Mobile Apps III. Briefly about Android 2) Introduction Android I. History Behind Android Development II.
More informationACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi
ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi View System A system for organizing GUI Screen = tree of views. View = rectangular shape on the screen that knows how to draw itself wrt to the containing
More informationMobile Application Development MyRent Settings
Mobile Application Development MyRent Settings Waterford Institute of Technology October 13, 2016 John Fitzgerald Waterford Institute of Technology, Mobile Application Development MyRent Settings 1/19
More informationMobile Development Lecture 11: Activity State and Preferences
Mobile Development Lecture 11: Activity State and Preferences Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com Activity Instance State Instance state: Current state of an activity. Which boxes
More informationLECTURE NOTES OF APPLICATION ACTIVITIES
Department of Information Networks The University of Babylon LECTURE NOTES OF APPLICATION ACTIVITIES By College of Information Technology, University of Babylon, Iraq Samaher@inet.uobabylon.edu.iq The
More informationRUNTIME PERMISSIONS IN ANDROID 6.0 Lecture 10a
RUNTIME PERMISSIONS IN ANDROID 6.0 Lecture 10a COMPSCI 702 Security for Smart-Devices Muhammad Rizwan Asghar March 20, 2018 2 ANDROID 6.0 A version of the Android mobile operating system officially released
More information07. Data Storage
07. Data Storage 22.03.2018 1 Agenda Data storage options How to store data in key-value pairs How to store structured data in a relational database 2 Data Storage Options Shared Preferences Store private
More informationAndroid: Data Storage
Android: Data Storage F. Mallet Frederic.Mallet@unice.fr Université Nice Sophia Antipolis Outline Data Storage Shared Preferences Internal Storage External Storage SQLite Databases Network Connection F.
More informationEMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State
EMBEDDED SYSTEMS PROGRAMMING 2016-17 Application Tip: Saving State THE PROBLEM How to save the state (of a UI, for instance) so that it survives even when the application is closed/killed The state should
More informationSolving an Android Threading Problem
Home Java News Brief Archive OCI Educational Services Solving an Android Threading Problem Introduction by Eric M. Burke, Principal Software Engineer Object Computing, Inc. (OCI) By now, you probably know
More informationCS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L
CS 370 Android Basics D R. M I C H A E L J. R E A L E F A L L 2 0 1 5 Activity Basics Manifest File AndroidManifest.xml Central configuration of Android application Defines: Name of application Icon for
More informationAndroid System Architecture. Android Application Fundamentals. Applications in Android. Apps in the Android OS. Program Model 8/31/2015
Android System Architecture Android Application Fundamentals Applications in Android All source code, resources, and data are compiled into a single archive file. The file uses the.apk suffix and is used
More informationUser Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.
User Interface Development CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath 1 Outline UI Support in Android Fragments 2 UI Support in the Android
More informationHow-to s and presentations. Be prepared to demo them in class. https://sites.google.com/site/androidhowto/presentati ons
Upcoming Assignments Readings: Chapter 6 by today Lab 3 due today (complete survey) Lab 4 will be available Friday (due February 5) Friday Quiz in Blackboard 2:10-3pm (Furlough) Vertical Prototype due
More informationAndroid development. Outline. Android Studio. Setting up Android Studio. 1. Set up Android Studio. Tiberiu Vilcu. 2.
Outline 1. Set up Android Studio Android development Tiberiu Vilcu Prepared for EECS 411 Sugih Jamin 15 September 2017 2. Create sample app 3. Add UI to see how the design interface works 4. Add some code
More informationCOSC 3P97 Mobile Computing
COSC 3P97 Mobile Computing Mobile Computing 1.1 COSC 3P97 Prerequisites COSC 2P13, 3P32 Staff instructor: Me! teaching assistant: Steve Tkachuk Lectures (MCD205) Web COSC: http://www.cosc.brocku.ca/ COSC
More informationMobile User Interfaces
Mobile User Interfaces CS 2046 Mobile Application Development Fall 2010 Announcements Next class = Lab session: Upson B7 Office Hours (starting 10/25): Me: MW 1:15-2:15 PM, Upson 360 Jae (TA): F 11:00
More informationAndroid Ecosystem and. Revised v4presenter. What s New
Android Ecosystem and Revised v4presenter What s New Why Mobile? 5B 4B 3B 2B 1B Landlines PCs TVs Bank users Mobiles 225M AOL 180M 135M 90M 45M 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Quarters
More informationMOBILE APPLICATIONS PROGRAMMING
Data Storage 23.12.2015 MOBILE APPLICATIONS PROGRAMMING Krzysztof Pawłowski Polsko-Japońska Akademia Technik Komputerowych STORAGE OPTIONS Shared Preferences SQLite Database Internal Storage External Storage
More informationapplication components
What you need to know for Lab 1 code to publish workflow application components activities An activity is an application component that provides a screen with which users can interact in order to do something,
More informationCOLLEGE OF ENGINEERING, NASHIK-4
Pune Vidyarthi Griha s COLLEGE OF ENGINEERING, NASHIK-4 DEPARTMENT OF COMPUTER ENGINEERING 1) What is Android? Important Android Questions It is an open-sourced operating system that is used primarily
More informationProduced by. Mobile Application Development. David Drohan Department of Computing & Mathematics Waterford Institute of Technology
Mobile Application Development Produced by David Drohan (ddrohan@wit.ie) Department of Computing & Mathematics Waterford Institute of Technology http://www.wit.ie User Interface Design" & Development -
More informationIn-app Billing Version 3
13 In-app Billing Version 3 Bruno Oliveira Developer Relations, Android 13 In-app billing! 2 In-app billing! Implement ALL the billing! 2 In-app billing! DO NOT WANT 2 PREVIOUSLY IN IN-APP BILLING 3 Easy
More informationAndroid Application Development Course 28 Contact Hours
Android Application Development Course 28 Contact Hours Course Overview This course that provides the required knowledge and skills to design and build a complete Androidâ application. It delivers an extensive
More informationCS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu
CS 4518 Mobile and Ubiquitous Computing Lecture 4: Data-Driven Views, Android Components & Android Activity Lifecycle Emmanuel Agu Announcements Group formation: Projects 2, 3 and final project will be
More informationGetting Started. Dr. Miguel A. Labrador Department of Computer Science & Engineering
Getting Started Dr. Miguel A. Labrador Department of Computer Science & Engineering labrador@csee.usf.edu http://www.csee.usf.edu/~labrador 1 Goals Setting up your development environment Android Framework
More informationEmbedded Systems Programming - PA8001
Embedded Systems Programming - PA8001 http://goo.gl/ydeczu Lecture 8 Mohammad Mousavi m.r.mousavi@hh.se Center for Research on Embedded Systems School of Information Science, Computer and Electrical Engineering
More informationAndroid Programming Lecture 8: Activities, Odds & Ends, Two New Views 9/28/2011
Android Programming Lecture 8: Activities, Odds & Ends, Two New Views 9/28/2011 Return Values from Activities: Callee Side How does the Sub-Activity send back a response? Create an Intent to return Stuff
More informationCSCU9YH: Development with Android
: Development with Android Computing Science and Mathematics University of Stirling Data Storage and Exchange 1 Preferences: Data Storage Options a lightweight mechanism to store and retrieve keyvalue
More informationMobile Application Development Android
Mobile Application Development Android Lecture 2 MTAT.03.262 Satish Srirama satish.srirama@ut.ee Android Lecture 1 -recap What is Android How to develop Android applications Run & debug the applications
More informationIntroduction to Android
Introduction to Android http://myphonedeals.co.uk/blog/33-the-smartphone-os-complete-comparison-chart www.techradar.com/news/phone-and-communications/mobile-phones/ios7-vs-android-jelly-bean-vs-windows-phone-8-vs-bb10-1159893
More informationProgramming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna
Programming with Android: Android for Tablets Luca Bedogni Marco Di Felice Dipartimento di Scienze dell Informazione Università di Bologna Outline Android for Tablets: A Case Study Android for Tablets:
More informationgetcount getitem getitemid getview com.taxi Class MainActivity drawerlayout drawerleft drawerright...
Contents com.taxi.ui Class CallDialog... 3 CallDialog... 4 show... 4 build... 5 com.taxi.custom Class CustomActivity... 5 TOUCH... 6 CustomActivity... 6 onoptionsitemselected... 6 onclick... 6 com.taxi.model
More informationAndroid App Development
Android App Development Course Contents: Android app development Course Benefit: You will learn how to Use Advance Features of Android with LIVE PROJECTS Original Fees: 15000 per student. Corporate Discount
More information