Exam 2 Review. Akhilesh Tyagi
|
|
- Kristopher Gardner
- 5 years ago
- Views:
Transcription
1 Exam 2 Review Akhilesh Tyagi
2 Design Flexibility An example of how two UI modules defined by fragments can be combined into one activity for a tablet design, but separated for a handset design
3 Using fragments in activity XML Activity layout XML can include fragments. <! activity_name.xml > <LinearLayout...> <fragment... android:name="classname1" /> <fragment... android:name="classname2" /> </LinearLayout> Marty Stepps, Stanford CS193A
4 Fragment Lifecycle
5 public class MySkeletonFragment extends Fragment { // Called when the Fragment is attached to its parent public void onattach(activity activity) { super.onattach(activity); // Get a reference to the parent Activity. // Called to do the initial creation of the public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // Initialize the Fragment.
6 oncreate(): The system calls this when creating the fragment. Within your implementation, you should initialize essential components of the fragment that you want to retain when the fragment is paused or stopped, then resumed. oncreateview(): The system calls this when it's time for the fragment to draw its user interface for the first time. To draw a UI for your fragment, you must return a View from this method that is the root of your fragment's layout. You can return null if the fragment does not provide a UI.
7 // Called once the Fragment has been created in order for it to // create its user public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { // Create, or inflate the Fragment's UI, and return it. // If this Fragment has no UI then return null. return inflater.inflate(r.layout.my_fragment, container, false); Resource file my_fragment.xml Should the inflated layout be attached To the container?
8 Fragment template public class Name extends Fragment public View oncreateview(layoutinflater inflater, ViewGroup vg, Bundle bundle) { // load the GUI layout from the XML return inflater.inflate(r.layout.id, vg, false); public void onactivitycreated(bundle savedstate) { super.onactivitycreated(savedstate); //... any other GUI initialization needed // any other code (e.g. event handling) Marty Stepps, Stanford CS193A
9 // Called at the start of the visible public void onstart(){ super.onstart(); // Apply any required UI change now that the Fragment is visible. // Called at the start of the active public void onresume(){ super.onresume(); // Resume any paused UI updates, threads, or processes required // by the Fragment but suspended when it became inactive.
10 // Called at the end of the active public void onpause(){ // Suspend UI updates, threads, or CPU intensive processes that don't //need to be updated when the Activity isn't the active foreground // activity. Persist all edits or state changes as after this call the process is likely to be killed. super.onpause(); // Called to save UI state changes at the // end of the active public void onsaveinstancestate(bundle savedinstancestate) { // Save UI state changes to the savedinstancestate. // This bundle will be passed to oncreate, oncreateview, and // oncreateview if the parent Activity is killed and restarted. super.onsaveinstancestate(savedinstancestate);
11 XML Fragment layouts Fragment element well suited for static layouts If the layout is to be dynamically modified in the program, use containers to pass to fragment managers.
12 <?xml version="1.0" encoding="utf 8"?> <LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="horizontal" xmlns:android=" "> <FrameLayout android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1" <FrameLayout android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="3" </LinearLayout>
13 Fragment Transactions To add, remove, and replace fragments within an activity. FragmentManager fragmanager = getfragmentmanager(); FragmentTransaction transaction = fragmanager.begintransaction(); transaction.add(r.id.container, firstfragment); transaction.commit();
14 public class MyFragmentActivity extends Activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // Inflate the layout containing the Fragment containers setcontentview(r.layout.fragment_container_layout); FragmentManager fm = getfragmentmanager(); // Check to see if the Fragment back stack has been populated // If not, create and populate the layout. DetailsFragment detailsfragment = (DetailsFragment) fm.findfragmentbyid(r.id.details_container);
15 if (detailsfragment == null) { FragmentTransaction ft = fm.begintransaction(); ft.add(r.id.details_container, new DetailsFragment()); ft.add(r.id.ui_container, new MyListFragment()); ft.commit();
16 Fragment vs. activity Fragment code is similar to activity code, with a few changes: Many activity methods aren't present in the fragment, but you can call getactivity to access the activity the fragment is inside of. Button b = (Button) findviewbyid(r.id.but); Button b = (Button) getactivity().findviewbyid(r.id.but); Sometimes also use getview to refer to the activity's layout Event handlers cannot be attached in the XML any more. : ( Must be attached in Java code instead. Passing information to a fragment (via Intents/Bundles) is trickier. The fragment must ask its enclosing activity for the information. Fragment initialization code must be mindful of order of execution. Does it depend on the surrounding activity being loaded? Etc. Typically move oncreate code to onactivitycreated. Marty Stepps, Stanford CS193A
17 Fragment onclick listener Activity: <Button android:onclick="onclickb1"... /> Fragment: <Button /> // in fragment's Java file Button b = (Button) getactivity().findviewbyid(r.id.b1); b.setonclicklistener(new View.OnClickListener() public void onclick(view view) { // whatever code would have been in onclickb1 ); Marty Stepps, Stanford CS193A
18 Communicating with the Activity a fragment can access the Activity instance with getactivity() and easily perform tasks such as find a view in the activity layout: View listview = getactivity().findviewbyid(r.id.list); activity can call methods in the fragment by acquiring a reference to the Fragment from FragmentManager, using findfragmentbyid() ExampleFragment fragment = (ExampleFragment) getfragmentmanager().findfragmentbyid(r.id.exampl e_fragment);
19 Fragment that accepts parameters public class Name extends Fragment public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { return inflater.inflate(r.layout.name, container, public void onactivitycreated(bundle savedstate) { super.onactivitycreated(savedstate); // extract parameters passed to activity from intent Intent intent = getactivity().getintent(); int name1 = intent.getintextra("id1", default); String name2 = intent.getstringextra("id2", "default"); // use parameters to set up the initial state... Marty Stepps, Stanford CS193A
20 Communication between fragments One activity might contain multiple fragments. Thefragmentsmaywanttotalktoeachother. Use activity's getfragmentmanager method. its findfragmentbyid method can access any fragment that has an id. Activity act = getactivity(); if (act.getresources().getconfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { // update other fragment within this same activity FragmentClass fragment = (FragmentClass) act.getfragmentmanager().findfragmentbyid(r.id.id); fragment.methodname(parameters); Marty Stepps, Stanford CS193A
21 Intents
22 Intents intent: a bridge between activities; a way for one activity to invoke another theactivitycanbeinthesameapporinadifferentapp can store extra data to pass as "parameters" to that activity second activity can "return" information back to the caller if needed Marty Stepps, CS193A, Stanford
23 Intent Object The main information that can be contained in an intent object : Component name: The name of the component that should handle the intent. Action: An action to be preformed such as initiating a phone call in an activity or handling a low battery warning in a broadcast. Data: Data to be acted on. Category: Additional information about the component handling the intent such as a widget, home, preference. Extras: Key value pairs containing additional information that should be passed to the component. Flags: These are contained in the intent API and have many different functions for the system on how to handle the intent.
24 Using Intents to Launch Activities To open a different application screen (Activity) in your application, call startactivity, passing in an Intent startactivity(myintent); The Intent can either explicitly specify the class to open, or include an action that the target should perform. Run time will choose the implicit Activity to open with Intent resolution.
25 Intent Resolution Intents can be divided into two groups: Explicit intents: These designate a component by name and are generally used locally for internal messages. Implicit intents: Do not name a target and are generally used by outside applications. For implicit intents the Android system will search components using intent filters to find the best match.
26 Implicit Intents and Late Runtime Binding Implicit Intents are a mechanism that lets anonymous application components service action requests. implicit Intent to use with startactivity, specifies an action to perform and, optionally, supplies the data on which to perform that action. if (foundphonenumer) { Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse( tel: )); startactivity(intent);
27 Extracting extra data In the second activity that was invoked, you can grab any extra data that was passed to it by the calling activity. You can access the Intent that spawned you by calling getintent. The Intent has methods like getextra, getintextra, getstringextra, etc. to extract any data that was stored inside the intent. public class SecondActivity extends Activity {... public void oncreate(bundle savedstate) { super.oncreate(savedstate); setcontentview(r.layout.activity_second); Intent intent = getintent(); String extra = intent.getextra("name");... Marty Stepps, CS193A, Stanford
28 Explicit Intent with Data/Arguments Intent i = new Intent(this, ActivityB.class); i.putextra("mystring1", "This is a message for ActivityB"); i.putextra("myint1", 100); startactivity(i); The data is received at the target activity as part of a Bundle object which can be obtained via a call to getintent().getextras(). ActivityB retrieves the data: Bundle extras = getintent().getextras(); if (extras!= null) { String mystring = extras.getstring("mystring1"); int myint = extras.getint("myint1");
29 Intents and Manifests <?xml version="1.0" encoding="utf 8"?> <manifest xmlns:android=" package="com.ebookfrenzy.intent1" android:versioncode="1" android:versionname="1.0" > <uses sdk android:minsdkversion="10" /> <application > <activity android:name="activitya" > <intent filter > <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent filter> </activity> <activity android:name="activityb" android:label="activityb" > </activity> </application> </manifest>
30 Subactivity ActivityB returns the result with: public void finish() { Intent data = new Intent(); data.putextra("returnstring1", "Message to parent activity"); setresult(result_ok, data); super.finish();
31 ActivityA receiving results protected void onactivityresult(int requestcode, int resultcode, Intent data) { String returnstring; if (resultcode == RESULT_OK && requestcode == REQUEST_CODE) { if (data.hasextra("returnstring1")) { returnstring = data.getextras().getstring("returnstring1");
32 Intent Filters Because intent filters must be seen by the Android system before launching a component; they are often placed in the Android Manifest file instead of Java Code. Implicit intents are tested against three filters of a component to see if they are correct. Action Category Data
33 Actions ACTION_CALL activity Initiate a phone call. ACTION_EDIT activity Display data for the user to edit. ACTION_MAIN activity Start up as the initial activity of a task, with no data input and no returned output. ACTION_SYNC activity Synchronize data on a server with data on the mobile device. ACTION_BATTERY_LOW broadcast receiver A warning that the battery is low. ACTION_HEADSET_PLUG broadcast receiver A headset has been plugged into the device, or unplugged from it. ACTION_SCREEN_ON broadcast receiver The screen has been turned on. ACTION_TIMEZONE_CHANGED broadcast receiver The setting for the time zone has changed.
34 Category category Use the android:category attribute to specify under which circumstances the action should be serviced ALTERNATIVE: The alternative category specifies that this action should be available as an alternative to the default action. BROWSABLE: Specifies an action available from within the browser
35 DEFAULT: Set this to make a component the default action. This is also necessary for Activities that are launched using an explicit Intent GADGET: By setting the gadget category, you specify that this Activity can run embedded inside another Activity. HOME: The home Activity is the first Activity displayed when the device starts LAUNCHER: Using this category makes an Activity appear in the application launcher.
36 Data Data tag specifies the data types handled by this component. android:host specifies a valid host name (iastate.edu) android:mimetype android:path valid path values for URIs android:port valid ports for a host
37 Intent Filter Example <activity android:name=.earthquakedamageviewer android:label= View Damage > <intent filter> <action android:name= com.paad.earthquake.intent.action.show_dam AGE > </action> <category android:name= android.intent.category.default /> <category android:name= android.intent.category.alternative_selected /> <data android:mimetype= vnd.earthquake.cursor.item/* /> </intent filter> </activity>
38 Listening for Broadcasts with Broadcast Receivers public class MyBroadcastReceiver extends BroadcastReceiver public void onreceive(context context, Intent intent) { //TODO: React to the Intent received. To enable a Broadcast Receiver, it needs to be registered, either in code or within the application manifest. When registering a Broadcast Receiver, you must use an Intent Filter to specify which Intents it is listening for.
39 public class LifeformDetectedBroadcastReceiver extends BroadcastReceiver { public static final String BURN = com.paad.alien.action.burn_it_with_fire public void onreceive(context context, Intent intent) { // Get the lifeform details from the intent. Uri data = intent.getdata(); String type = intent.getstringextra( type ); double lat = intent.getdoubleextra( latitude, 0); double lng = intent.getdoubleextra( longitude, 0); Location loc = new Location( gps ); loc.setlatitude(lat); loc.setlongitude(lng); if (type.equals( alien )) { Intent startintent = new Intent(BURN, data); startintent.putextra( latitude, lat); StartIntent.putExtra( longitude, lng); context.startactivity(startintent);
40 Registering Broadcast Receivers in Application Manifest <receiver android:name=.lifeformdetectedbroadcastrec eiver > <intent filter> <action android:name= com.paad.action.new_lif EFORM /> </intent filter> </receiver>
41 Registering Broadcast Receivers in Code // Create and register the broadcast receiver. IntentFilter filter = new IntentFilter(NEW_LIFEFORM_DETECTED); LifeformDetectedBroadcastReceiver r = new LifeformDetectedBroadcastReceiver(); registerreceiver(r, filter);
42 Preferences storage A SharedPreferences object points to a file containing key value pairs and provides simple methods to read and write them. getsharedpreferences() Use this if you need multiple shared preference files identified by name, which you specify with the first parameter. You can call this from any Context in your app. getpreferences() Use this from an Activity if you need to use only one shared preference file for the activity. Because this retrieves a default shared preference file that belongs to the activity, you don't need to supply a name.
43 SharedPreferences files accesses the shared preferences file that's identified by the resource string R.string.preference_file_key and opens it using the private mode so the file is accessible by only your app. When naming your shared preference files, you should use a name that's uniquely identifiable to your app, such as "com.example.myapp.preference_file_key" Context context = getactivity(); SharedPreferences sharedpref = context.getsharedpreferences( getstring(r.string.preference_file_key), Context.MODE_PRIVATE);
44 Nameless Activity SharedPrerences file SharedPreferences sharedpref = getactivity().getpreferences(context.mode_p RIVATE); If you create a shared preferences file with MODE_WORLD_READABLE or MODE_W ORLD_WRITEABLE, then any other apps that know the file identifier can access your data.
45 SharedPreferences sharedpref = getactivity().getpreferences (Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedpref.edit(); editor.putint(getstring(r.string.saved_high_score), newhighscore); editor.putboolean( istrue, true); editor.putfloat( lastfloat, 1f); editor.putint( wholenumber, 2); editor.putlong( anumber, 31); editor.putstring( textentryvalue, Not Empty ); editor.commit();
46 Read from Shared Preferences call methods such as getint() and getstring(), providing the key for the value you want, and optionally a default value to return if the key isn't present SharedPreferences sharedpref = getactivity().getpreferences(context.mode_private); int defaultvalue = getresources().getinteger(r.string.saved_high_score_ default); long highscore = sharedpref.getint(getstring(r.string.saved_high_score), defaultvalue);
47 boolean istrue = mysharedpreferences.getboolean( istrue, false); float lastfloat = mysharedpreferences.getfloat( lastfloat, 0f); int wholenumber = mysharedpreferences.getint( wholenumber, 1); long anumber = mysharedpreferences.getlong( anumber, 0); stringpreference = mysharedpreferences.getstring( textentryvalue, );
48 Multiple preference files You can call getsharedpreferences and supply a file name if you want to have multiple pref. files for the same activity: SharedPreferences prefs = getsharedpreferences( "filename", MODE_PRIVATE); SharedPreferences.Editor prefseditor = prefs.edit(); prefseditor.putint("name", value); prefseditor.putstring("name", value);... prefseditor.commit(); Marty Stepps, CS193A, Stanford
49 msensormanager = (SensorManager) getsystemservice(context.sensor_service); if (msensormanager.getdefaultsensor(sensor.type_gravity)!= null){ List<Sensor> gravsensors = msensormanager.getsensorlist(sensor.type_gravity); for(int i=0; i<gravsensors.size(); i++) { if ((gravsensors.get(i).getvendor().contains("google Inc.")) && (gravsensors.get(i).getversion() == 3)){ // Use the version 3 gravity sensor. msensor = gravsensors.get(i);
50 else{ // Use the accelerometer. if (msensormanager.getdefaultsensor(sensor.type_accelerometer)!= null){ msensor = msensormanager.getdefaultsensor(sensor.type_accelerometer); else{ // Sorry, there are no accelerometers on your device. // You can't play this game.
51 public class SensorActivity extends Activity implements SensorEventListener { private SensorManager msensormanager; private Sensor public final void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msensormanager = (SensorManager) getsystemservice(context.sensor_service); mlight = msensormanager.getdefaultsensor(sensor.type_light);
52 Putting it all together Accelerometer public class sensorexample extends Activity implements SensorEventListener { private SensorManager sensensormanager; private Sensor protected void oncreate(bundle savedinstancestate) { Reference to system sensor service Reference to default accelerometer Need to check if it exists super.oncreate(savedinstancestate); setcontentview(r.layout.activity_sensorexample); sensensormanager = (SensorManager) getsystemservice(context.sensor_service); senaccelerometer = sensensormanager.getdefaultsensor(sensor.type_accelerometer); sensensormanager.registerlistener(this, senaccelerometer, SensorManager.SENSOR_DELAY_NORMAL); Register the listener to call back when sensor event occurs
53 Called when accelerometer registers a new event such as motion along any public void onsensorchanged(sensorevent sensorevent) { Sensor mysensor = sensorevent.sensor; if (mysensor.gettype() == Sensor.TYPE_ACCELEROMETER) { float x = sensorevent.values[0]; float y = sensorevent.values[1]; float z = public void onaccuracychanged(sensor sensor, int accuracy) { Acceleration values along the three axis
54 protected void onpause() { super.onpause(); sensensormanager.unregisterlistener(this); Important Sensors drain battery resource. Sensors keep acquiring data during onpause if not unregistered protected void onresume() { super.onresume(); sensensormanager.registerlistener(this, senaccelerometer, SensorManager.SENSOR_DELAY_NORMAL); Re-register Sensorevent listener to continue acquiring data during onresume
Mobile Development Lecture 10: Fragments
Mobile Development Lecture 10: Fragments Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com Situational Layouts Your app can use different layout in different situations: different device type
More informationFragments. Lecture 11
Fragments Lecture 11 Situational layouts Your app can use different layouts in different situations Different device type (tablet vs. phone vs. watch) Different screen size Different orientation (portrait
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 informationCS 193A. Multiple Activities and Intents
CS 193A Multiple Activities and Intents This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Multiple
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 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 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 informationFragments. Lecture 10
Fragments Lecture 10 Situa2onal layouts Your app can use different layouts in different situa2ons Different device type (tablet vs. phone vs. watch) Different screen size Different orienta2on (portrait
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 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 informationMultiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers
Multiple devices Multiple devices Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers Create a new directory in your project's res/ and name it using the
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 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 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 Development Lecture 8: Intents and Animation
Mobile Development Lecture 8: Intents and Animation Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Elgayyar.weebly.com 1. Multiple Activities Intents Multiple Activities Many apps have multiple activities.
More informationXin Pan. CSCI Fall
Xin Pan CSCI5448 2011 Fall Outline Introduction of Android System Four primary application components AndroidManifest.xml Introduction of Android Sensor Framework Package Interface Classes Examples of
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 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 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 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 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 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 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 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 informationELET4133: Embedded Systems. Topic 15 Sensors
ELET4133: Embedded Systems Topic 15 Sensors Agenda What is a sensor? Different types of sensors Detecting sensors Example application of the accelerometer 2 What is a sensor? Piece of hardware that collects
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 informationProgramming with Android: Activities and Intents. Dipartimento di Informatica Scienza e Ingegneria Università di Bologna
Programming with Android: Activities and Intents Luca Bedogni Marco Di Felice Dipartimento di Informatica Scienza e Ingegneria Università di Bologna Outline What is an intent? Intent description Handling
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 informationMobile Programming Lecture 9. Bound Services, Location, Sensors, IntentFilter
Mobile Programming Lecture 9 Bound Services, Location, Sensors, IntentFilter Agenda Bound Services Location Sensors Starting an Activity for a Result Understanding Implicit Intents Bound Service When you
More informationstolen from Intents and Intent Filters
stolen from http://developer.android.com/guide/components/intents-filters.html Intents and Intent Filters Three of the core components of an application activities, services, and broadcast receivers are
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 informationMODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING
This document can be downloaded from www.chetanahegde.in with most recent updates. 1 MODULE 2: GETTING STARTED WITH ANDROID PROGRAMMING Syllabus: What is Android? Obtaining the required tools, Anatomy
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 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 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 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 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 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 informationInitialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III)
5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III) Dr Dimitris C. Dracopoulos Making a Move (GameFragment) Dimitris C. Dracopoulos 1/22 Initialising
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 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 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 informationHave a development environment in 256 or 255 Be familiar with the application lifecycle
Upcoming Assignments Readings: Chapter 4 by today Horizontal Prototype due Friday, January 22 Quiz 2 today at 2:40pm Lab Quiz next Friday during lecture time (2:10-3pm) Have a development environment in
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 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 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 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 informationAndroid Basics. Android UI Architecture. Android UI 1
Android Basics Android UI Architecture Android UI 1 Android Design Constraints Limited resources like memory, processing, battery à Android stops your app when not in use Primarily touch interaction à
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 informationMobila applikationer och trådlösa nät, HI1033, HT2012
Mobila applikationer och trådlösa nät, HI1033, HT2012 Today: - User Interface basics - View components - Event driven applications and callbacks - Menu and Context Menu - ListView and Adapters - Android
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 informationFRAGMENTS.
Fragments 69 FRAGMENTS In the previous section you learned what an activity is and how to use it. In a small-screen device (such as a smartphone), an activity typically fi lls the entire screen, displaying
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 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 informationVienos veiklos būsena. Theory
Vienos veiklos būsena Theory While application is running, we create new Activities and close old ones, hide the application and open it again and so on, and Activity can process all these events. It is
More informationListView Containers. Resources. Creating a ListView
ListView Containers Resources https://developer.android.com/guide/topics/ui/layout/listview.html https://developer.android.com/reference/android/widget/listview.html Creating a ListView A ListView is a
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 informationIslamic University of Gaza. Faculty of Engineering. Computer Engineering Department. Mobile Computing ECOM Eng. Wafaa Audah.
Islamic University of Gaza Faculty of Engineering Computer Engineering Department Mobile Computing ECOM 5341 By Eng. Wafaa Audah July 2013 1 Launch activitits, implicit intents, data passing & start activity
More informationIntroduction to Android
Introduction to Android Ambient intelligence Alberto Monge Roffarello Politecnico di Torino, 2017/2018 Some slides and figures are taken from the Mobile Application Development (MAD) course Disclaimer
More informationProgrammation Mobile Android Master CCI
Programmation Mobile Android Master CCI Bertrand Estellon Aix-Marseille Université March 23, 2015 Bertrand Estellon (AMU) Android Master CCI March 23, 2015 1 / 266 Navigation entre applications Nous allons
More informationAssignment 1. Start: 28 September 2015 End: 9 October Task Points Total 10
Assignment 1 Start: 28 September 2015 End: 9 October 2015 Objectives The goal of this assignment is to familiarize yourself with the Android development process, to think about user interface design, and
More informationAction Bar. (c) 2010 Haim Michael. All Rights Reserv ed.
Action Bar Introduction The Action Bar is a widget that is shown on top of the screen. It includes the application logo on its left side together with items available from the options menu on the right.
More informationCS 4330/5390: Mobile Application Development Exam 1
1 Spring 2017 (Thursday, March 9) Name: CS 4330/5390: Mobile Application Development Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and closed-book.
More informationFragments. Fragments may only be used as part of an ac5vity and cannot be instan5ated as standalone applica5on elements.
Fragments Fragments A fragment is a self- contained, modular sec5on of an applica5on s user interface and corresponding behavior that can be embedded within an ac5vity. Fragments can be assembled to create
More informationSoftware Practice 3 Today s lecture Today s Task Porting Android App. in real device
1 Software Practice 3 Today s lecture Today s Task Porting Android App. in real device Prof. Hwansoo Han T.A. Jeonghwan Park 43 INTENT 2 3 Android Intent An abstract description of a message Request actions
More informationBasic UI elements: Defining Activity UI in the code. Marco Ronchetti Università degli Studi di Trento
1 Basic UI elements: Defining Activity UI in the code Marco Ronchetti Università degli Studi di Trento UI Programmatically public class UIThroughCode extends Activity { LinearLayout llayout; TextView tview;
More informationAPI Guide for Gesture Recognition Engine. Version 2.0
API Guide for Gesture Recognition Engine Version 2.0 Table of Contents Gesture Recognition API... 3 API URI... 3 Communication Protocol... 3 Getting Started... 4 Protobuf... 4 WebSocket Library... 4 Project
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 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 informationReal-Time Embedded Systems
Real-Time Embedded Systems DT8025, Fall 2016 http://goo.gl/azfc9l Lecture 8 Masoumeh Taromirad m.taromirad@hh.se Center for Research on Embedded Systems School of Information Technology 1 / 51 Smart phones
More informationOverview. Lecture: Implicit Calling via Share Implicit Receiving via Share Launch Telephone Launch Settings Homework
Implicit Intents Overview Lecture: Implicit Calling via Share Implicit Receiving via Share Launch Telephone Launch Settings Homework Intents Intent asynchronous message used to activate one Android component
More informationSensor & SensorManager SensorEvent & SensorEventListener Filtering sensor values Example applications
Sensor & SensorManager SensorEvent & SensorEventListener Filtering sensor values Example applications Hardware devices that measure the physical environment Motion Position Environment Motion - 3-axis
More informationLecture 7: Data Persistence : shared preferences. Lecturer : Ali Kadhim Al-Bermani Mobile Fundamentals and Programming
University of Babylon College of Information Technology Department of Information Networks Mobile Fundamentals and Programming Lecture 7: Data Persistence : shared preferences Lecturer : Ali Kadhim Al-Bermani
More informationBasic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento
Basic UI elements: Android Buttons (Basics) Marco Ronchetti Università degli Studi di Trento Let s work with the listener Button button = ; button.setonclicklistener(new.onclicklistener() { public void
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 informationAndroid. Operating System and Architecture. Android. Screens. Main features
Android Android Operating System and Architecture Operating System and development system from Google and Open Handset Alliance since 2008 At the lower level is based on the Linux kernel and in a higher
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 informationSpring Lecture 5 Lecturer: Omid Jafarinezhad
Mobile Programming Sharif University of Technology Spring 2016 - Lecture 5 Lecturer: Omid Jafarinezhad Storage Options Android provides several options for you to save persistent application data. The
More informationAndroid Overview. Most of the material in this section comes from
Android Overview Most of the material in this section comes from http://developer.android.com/guide/ Android Overview A software stack for mobile devices Developed and managed by Open Handset Alliance
More informationCreating a Custom ListView
Creating a Custom ListView References https://developer.android.com/guide/topics/ui/declaring-layout.html#adapterviews Overview The ListView in the previous tutorial creates a TextView object for each
More informationLifeStreet Media Android Publisher SDK Integration Guide
LifeStreet Media Android Publisher SDK Integration Guide Version 1.12.0 Copyright 2015 Lifestreet Corporation Contents Introduction... 3 Downloading the SDK... 3 Choose type of SDK... 3 Adding the LSM
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 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 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 informationAndroid Services. Victor Matos Cleveland State University. Services
22 Android Victor Matos Cleveland State University Notes are based on: Android Developers http://developer.android.com/index.html 22. Android Android A Service is an application component that runs in
More informationStarting Another Activity Preferences
Starting Another Activity Preferences Android Application Development Training Xorsat Pvt. Ltd www.xorsat.net fb.com/xorsat.education Outline Starting Another Activity Respond to the Button Create the
More informationFragment Example Create the following files and test the application on emulator or device.
Fragment Example Create the following files and test the application on emulator or device. File: AndroidManifest.xml
More informationOur First Android Application
Mobile Application Development Lecture 04 Imran Ihsan Our First Android Application Even though the HelloWorld program is trivial in introduces a wealth of new ideas the framework, activities, manifest,
More informationUsing Intents to Launch Activities
Using Intents to Launch Activities The most common use of Intents is to bind your application components. Intents are used to start, stop, and transition between the Activities within an application. The
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 informationEMBEDDED SYSTEMS PROGRAMMING UI and Android
EMBEDDED SYSTEMS PROGRAMMING 2016-17 UI and Android STANDARD GESTURES (1/2) UI classes inheriting from View allow to set listeners that respond to basic gestures. Listeners are defined by suitable interfaces.
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 informationCS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars
CS371m - Mobile Computing More UI Navigation, Fragments, and App / Action Bars EFFECTIVE ANDROID NAVIGATION 2 Clicker Question Have you heard of the terms Back and Up in the context of Android Navigation?
More informationProduced by. Mobile Application Development. Higher Diploma in Science in Computer Science. Eamonn de Leastar
Mobile Application Development Higher Diploma in Science in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology
More informationWorkshop. 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking
Workshop 1. Create a simple Intent (Page 1 2) Launch a Camera for Photo Taking 2. Create Intent with Parsing Data (Page 3 8) Making Phone Call and Dial Access Web Content Playing YouTube Video 3. Create
More informationAPI Guide for Gesture Recognition Engine. Version 1.1
API Guide for Gesture Recognition Engine Version 1.1 Table of Contents Table of Contents... 2 Gesture Recognition API... 3 API URI... 3 Communication Protocol... 3 Getting Started... 4 Protobuf... 4 WebSocket
More informationCS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments
CS371m - Mobile Computing More UI Action Bar, Navigation, and Fragments ACTION BAR 2 Options Menu and Action Bar prior to Android 3.0 / API level 11 Android devices required a dedicated menu button Pressing
More informationTopics Related. SensorManager & Sensor SensorEvent & SensorEventListener Filtering Sensor Values Example applications
Sensors Lecture 23 Context-aware System a system is context-aware if it uses context to provide relevant information and/or services to the user, where relevancy depends on the user s task. adapt operations
More informationfilled by the user and display it by setting the value of view elements. Uses display.xml as layout file to display the result.
Project Description Form Activity: main activity which is presented to the user when launching the application for the first time. It displays a form and allows the user to fill and submit the form. When
More informationGetting started: Installing IDE and SDK. Marco Ronchetti Università degli Studi di Trento
Getting started: Installing IDE and SDK Marco Ronchetti Università degli Studi di Trento Alternative: Android Studio http://developer.android.com/develop/index.html 2 Tools behind the scenes dx allows
More information