Mobile Programming Lecture 9. Bound Services, Location, Sensors, IntentFilter
|
|
- Paula O’Brien’
- 6 years ago
- Views:
Transcription
1 Mobile Programming Lecture 9 Bound Services, Location, Sensors, IntentFilter
2 Agenda Bound Services Location Sensors Starting an Activity for a Result Understanding Implicit Intents
3 Bound Service When you create a Bound Service, you must provide an IBinder that provides the programming interface that clients can use to interact with the Service There are 3 ways that you can provide this interface: 1. Extending the Binder class 2. Using a Messenger 3. Using AIDL
4 Bound Service
5 Bound Service - 1 extending Binder This is the preferred technique when your service is merely a background worker for your own application The only reason you would not create your interface this way is because your service is used by other applications or across separate processes
6 Bound Service - 1 extending Binder Here's how to set it up 1. In your service, create an instance of Binder that returns the current Service instance, which has public methods the client can call 2. Return this instance of Binder from the onbind() callback method 3. In the client, receive the Binder from the onserviceconnected() callback method and make calls to the bound service using the methods provided
7 Bound Service - 1 extending Binder See BoundServiceBinder Example ServiceConnection class monitors the connection between the client and the Service When a Service is bound, the binder returned is returned to the onserviceconnected() method of ServiceConnection
8 Bound Service - 2 using Messenger If you need your interface to work across different processes, you can create an interface for the service with a Messenger The service defines a Handler that responds to different types of Message objects Additionally, the client can define a Messenger of it's own so the service can send messages back. This is the simplest way to perform interprocess communication (IPC), because the Messenger queues all requests into a single thread so that you don't have to design your service to be thread-safe
9 Bound Service - 2 using Messenger Notice that the handlemessage() method in the Handler is where the service receives the incoming Message and decides what to do, based on the what member.
10 Bound Service - 2 using Messenger See BoundServiceMessenger Example
11 Bound Service - 3 using the AIDL Using AIDL is way too specific Has benefits over extending Binder Supports parcelable objects Can be accessed from different applications (API) Handles multithreading We won't cover this, but you can read more about it here
12 Location Providers To obtain user location, you can use GPS Most accurate But Consumes battery power fast Takes a while to determine location Network Location Provider
13 Location - LocationManager Requesting Location Updates To get the user s location, you need to use the LocationManager, which is a system service This returns a Location object, which can tell you Latitude Longitude Distance between two locations (comparing to another Location object) Accuracy of the Location in meters Direction of travel in degrees Speed of travel in meters per second The Location, however, does not give you any human readable address such as street name, state, or country
14 Location - Geocoder and Address Requesting Location Updates You can use the Location object to obtain a human-readable address by using a Geocoder Geocoder can give you a list of addresses (since it may not always be sure because of accuracy issues) Returns a List of Address objects, i.e. List<Address> Street name City State Country Zip Code
15 Location - Last Known Location Since GPS and Wifi location are not quite instantaneous, you can get the last known location until one of them becomes available
16 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Location lastloc = lm.getlastknownlocation( LocationManager.NETWORK_PROVIDER); Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), lastloc.getlongitude(), 1); ); if (addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
17 Location - Last Known Location final LocationManager lm = (LocationManager) getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Location lastloc = lm.getlastknownlocation( getsystemservice(context.location_service); LocationManager.NETWORK_PROVIDER); Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), Similar to getting the system service for the DownloadManager lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
18 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Location lastloc = lm.getlastknownlocation( LocationManager.NETWORK_PROVIDER); Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), What was the last known location? lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
19 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() { We need to Geocoder to transform public void onclick(view v) longitude { and latitude to Location lastloc = lm.getlastknownlocation( an address LocationManager.NETWORK_PROVIDER); Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
20 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { We will store said Location lastloc = lm.getlastknownlocation( address here LocationManager.NETWORK_PROVIDER); Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
21 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Let's get a List of Location lastloc = lm.getlastknownlocation( Addresses (although there may be only LocationManager.NETWORK_PROVIDER); 1 Geocoder geo = new Geocoder(getApplicationContext()); sometimes) List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
22 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Location lastloc = lm.getlastknownlocation( Pass LocationManager.NETWORK_PROVIDER); the latitude... Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
23 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Location lastloc = lm.getlastknownlocation( LocationManager.NETWORK_PROVIDER); Geocoder geo = new Geocoder(getApplicationContext()); the longitude... List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
24 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Location lastloc = lm.getlastknownlocation( LocationManager.NETWORK_PROVIDER); and the max number of Geocoder geo = new Geocoder(getApplicationContext()); addresses that you want to be returned List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), lastloc.getlongitude(), 1); ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
25 Location - Last Known Location final LocationManager lm = (LocationManager) getsystemservice(context.location_service); getbutton = (Button) findviewbyid(r.id.button1); tv = (TextView) findviewbyid(r.id.textview1); getbutton.setonclicklistener(new View.OnClickListener() public void onclick(view v) { Location lastloc = lm.getlastknownlocation( LocationManager.NETWORK_PROVIDER); Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses; addresses = geo.getfromlocation(lastloc.getlatitude(), Get the first line of the lastloc.getlongitude(), 1); first address in the list ); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0));
26 Location - Last Known Location See LastKnownLocation Example
27 Location - Location Updates Requesting Location Updates To get actual location updates periodically, you should use a LocationListener At some point, you should stop requesting location updates, possibly when Activity loses focus You no longer need the location
28 Location - Location Updates final LocationManager lm = (LocationManager) getsystemservice( LOCATION_SERVICE); final LocationListener ll = new LocationListener() public void onstatuschanged(string provider, int status, Bundle extras) public void onproviderenabled(string provider) public void onproviderdisabled(string provider) public void onlocationchanged(location location) { Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses = null; addresses = geo.getfromlocation(location.getlatitude(), location.getlongitude(), 1); if (addresses!= null) tv.settext(addresses.get(0).getaddressline(0)); ; lm.removeupdates( this);
29 Location - Location Updates final LocationManager lm = (LocationManager) getsystemservice(location_service); final LocationListener ll = new LocationListener() public void onstatuschanged(string provider, int status, Bundle extras) public void onproviderenabled(string provider) public void onproviderdisabled(string provider) { We need to register a LocationListener if we want to get updates on the location public void onlocationchanged(location location) { Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses = null; addresses = geo.getfromlocation(location.getlatitude(), location.getlongitude(), 1); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0)); ; lm.removeupdates(this);
30 Location - Location Updates final LocationManager lm = (LocationManager) getsystemservice(location_service); final LocationListener ll = new LocationListener() public void onstatuschanged(string provider, int status, Bundle extras) public void onproviderenabled(string provider) public void onproviderdisabled(string provider) public void onlocationchanged(location location) { Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses = null; addresses = geo.getfromlocation(location.getlatitude(), if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0)); We're forced to override these methods, although we don't use them location.getlongitude(), 1); ; lm.removeupdates(this);
31 Location - Location Updates final LocationManager lm = (LocationManager) getsystemservice(location_service); final LocationListener ll = new LocationListener() public void onstatuschanged(string provider, int status, Bundle extras) public void onproviderenabled(string provider) public void onproviderdisabled(string provider) public void onlocationchanged(location location) { Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses = null; addresses = geo.getfromlocation(location.getlatitude(), if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0)); In this callback method is where you code your response to a location change location.getlongitude(), 1); ; lm.removeupdates(this);
32 Location - Location Updates final LocationManager lm = (LocationManager) getsystemservice(location_service); final LocationListener ll = new LocationListener() public void onstatuschanged(string provider, int status, Bundle extras) public void onproviderenabled(string provider) public void onproviderdisabled(string provider) { Nothing new public void onlocationchanged(location location) { Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses = null; addresses = geo.getfromlocation(location.getlatitude(), location.getlongitude(), 1); if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0)); ; lm.removeupdates(this);
33 Location - Location Updates final LocationManager lm = (LocationManager) getsystemservice(location_service); final LocationListener ll = new LocationListener() public void onstatuschanged(string provider, int status, Bundle extras) public void onproviderenabled(string provider) public void onproviderdisabled(string provider) { public void onlocationchanged(location location) { Geocoder geo = new Geocoder(getApplicationContext()); List<Address> addresses = null; addresses = geo.getfromlocation(location.getlatitude(), if(addresses!= null) tv.settext(addresses.get(0).getaddressline(0)); lm.removeupdates(this); Let's save battery life and stop listening for updates, although you may choose to stop listening for updates at some other point if you want to location.getlongitude(), 1);
34 Location - Location Updates See LocationManager Example
35 Location - Proximity Alert Sometimes instead of retrieving the current location, you may want to know when the user arrives at a certain location For example, in turn-by-turn directions, you may want to know when the user is close to the next turning point You can use the addproximityalert() method of the LocationManager to accomplish this This registers a PendingIntent
36 Location - Proximity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); LocationManager lm = (LocationManager) getsystemservice(location_service); PendingIntent pi = creatependingresult(1, new Intent(), 0); Location loc = lm.getlastknownlocation(locationmanager.gps_provider); lm.addproximityalert(loc.getlatitude(), loc.getlongitude(), 10, -1, pi); Toast.makeText(this, "You're on the way", public void onactivityresult(int reqcode, int resultcode, Intent data) { Toast.makeText(this, "You have arrived", Toast.LENGTH_SHORT).show();
37 Location - Proximity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); LocationManager lm = (LocationManager) getsystemservice(location_service); PendingIntent pi = creatependingresult(1, new Intent(), 0); We've used PendingIntent this way before when we talked about Services Location loc = lm.getlastknownlocation(locationmanager.gps_provider); lm.addproximityalert(loc.getlatitude(), loc.getlongitude(), 10, -1, pi); Toast.makeText(this, "You're on the way", public void onactivityresult(int reqcode, int resultcode, Intent data) { Toast.makeText(this, "You have arrived", Toast.LENGTH_SHORT).show();
38 Location - Proximity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); LocationManager lm = (LocationManager) getsystemservice(location_service); Let's see how long it takes for the system to tell PendingIntent pi = creatependingresult(1, new Intent(), 0); us when we get back to our last known location Location loc = lm.getlastknownlocation(locationmanager.gps_provider); lm.addproximityalert(loc.getlatitude(), loc.getlongitude(), 10, -1, pi); Toast.makeText(this, "You're on the way", public void onactivityresult(int reqcode, int resultcode, Intent data) { Toast.makeText(this, "You have arrived", Toast.LENGTH_SHORT).show();
39 Location - Proximity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); LocationManager lm = (LocationManager) getsystemservice(location_service); PendingIntent pi = creatependingresult(1, new Intent(), 0); Location loc = lm.getlastknownlocation(locationmanager.gps_provider); lm.addproximityalert(loc.getlatitude(), loc.getlongitude(), 10, -1, pi); Toast.makeText(this, "You're on the way", Toast.LENGTH_SHORT).show(); Whenever we get to that location, this callback method will handle the public void onactivityresult(int reqcode, int resultcode, Intent data) { Toast.makeText(this, "You have arrived", Toast.LENGTH_SHORT).show();
40 Location - Proximity Alert See LocationProximityAlert Example
41 Location - Permissions In order to receive location updates from NETWORK_PROVIDER or GPS_PROVIDER, you must request user permission by declaring one or both of the following permissions ACCESS_COARSE_LOCATION (Wifi location) ACCESS_FINE_LOCATION (GPS location)
42 Location - Mock Location You can test your location-based features by mocking location data in the Emulator ning-user-location.html#mockdata The Emulator uses the GPS provider Found under the Emulator Control View in Android Device Monitor, under the Emulator Control view You can open Android Device Monitor from Android Studio Tools > Android > Android Device Monitor
43 Sensor Accelerometer Gyroscope Light Orientation (DEPRECATED!) Proximity Pressure and more See SensorList Example
44 SensorManager SensorManager lets you access the device's sensors. Get an instance of this class by calling Context.getSystemService() with the argument SENSOR_SERVICE. Always make sure to disable sensors you don't need, especially when your activity is paused Failing to do so can drain the battery in just a few hours The system will not disable sensors automatically when the screen turns off.
45 SensorEvent The values for each sensor may change at some point Set up an Event Listener to take action when these change These values can be retrieved from a float values[] array, regardless of the type of sensor
46 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener { SensorManager msensormanager; Sensor mproximity; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout. main); msensormanager = (SensorManager)getSystemService( SENSOR_SERVICE); mproximity = msensormanager.getdefaultsensor(sensor. TYPE_PROXIMITY);...
47 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener { SensorManager Because we want msensormanager; to know when there's a SensorEvent, Sensor when values mproximity; of the Sensor change public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msensormanager = (SensorManager)getSystemService(SENSOR_SERVICE); mproximity = msensormanager.getdefaultsensor(sensor.type_proximity);...
48 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener { SensorManager msensormanager; Sensor mproximity; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Similar to how we got the Location service msensormanager = (SensorManager)getSystemService(SENSOR_SERVICE); mproximity = msensormanager.getdefaultsensor(sensor.type_proximity);...
49 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener { SensorManager msensormanager; Sensor mproximity; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msensormanager = (SensorManager)getSystemService(SENSOR_SERVICE); mproximity = msensormanager.getdefaultsensor(sensor.type_proximity); Let's get a Sensor...
50 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener { SensorManager msensormanager; Sensor mproximity; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main);... msensormanager = (SensorManager)getSystemService(SENSOR_SERVICE); mproximity = msensormanager.getdefaultsensor( Sensor.TYPE_PROXIMITY); The Proximity Sensor specifically
51 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener { SensorManager msensormanager; Sensor mproximity; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); msensormanager = (SensorManager)getSystemService(SENSOR_SERVICE); mproximity = msensormanager.getdefaultsensor(sensor.type_proximity);... The rest of the code for this class on the next slide
52 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... oncreate() is here somewhere, on the protected previous void onresume() page { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
53 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); protected void onpause() { Note that this is onresume() super.onpause(); msensormanager.unregisterlistener(this); public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
54 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, We only want to listen when the Activity is visible in this case, so protected we do void this onpause() in onresume() { super.onpause(); msensormanager.unregisterlistener(this); SensorManager.SENSOR_DELAY_NORMAL); public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
55 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); We pass a Context... protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
56 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); a Sensor... protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
57 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); SensorManager.SENSOR_DELAY_NORMAL); and the rate we want sensor events to be delivered public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
58 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); in onpause(), we want to stop listening for updates, preserving battery life public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
59 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); This is where we take action when there is a change in Sensor values public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
60 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show(); event.values[] array has important data about the sensor event
61 SensorEvent public class SensorExampleActivity extends Activity implements SensorEventListener {... protected void onresume() { super.onresume(); msensormanager.registerlistener(this, mproximity, SensorManager.SENSOR_DELAY_NORMAL); protected void onpause() { super.onpause(); msensormanager.unregisterlistener(this); Refer to this page for details for each type of Sensor public void onsensorchanged(sensorevent event) { Toast.makeText(this, "Proximity = " + event.values[0], Toast.LENGTH_SHORT).show();
62 SensorEvent See: ProximitySensor Example LightSensor Example The code change between these two examples is very small
63 Using Sensors to Create a NUI NUI = Natural User Interface Human Computer Interaction is moving further and further away from the mouse and keyboard. Being replaced by gestures on the device, air gestures, speech recognition, and kinetics. There are typically two phases to gesture recognition Data Gathering Gesture Detection
64 Touch Using Gesture Detection you can register to listen for touch events on the device. Long Press Double Tap Fling Pinch Multiple Finger gestures
65 Telepathy Can think of this gesture as an air gesture Passing your hand over the device without touching the screen Might think that this would require a front facing camera to process this gesture.. This would be an option but there is an easier way Use the Light Sensor to recognize the gesture And the Proximity Sensor to validate
66 Kinetics This is the term for gestures using the device itself Taking advantage of the accelerometer, gravity sensor, gyroscope, compass, etc ICS - Huge improvement for gyroscope Things to look out for Power consumption Sampling Rate Varies by phone and is in nanoseconds NOT milliseconds Also, it is not synced with system time! Event comes with timestamp There will always be static and random variation Accelerometer data
67 Microphone Using Speech is a no brainer for NUI ch/recognizerintent.html A more technical way of using the microphone requires signal processing Way, way, way outside the scope of this class
68 Making Sense of the Data Thresholds Time Check peaks Filter peaks that are too close Based on count Combine with sensor data to get heart rate, for example Statistics are your friend Since sensors spit out messy and noisy data Mean, median, mode, range, etc
69 Starting Activities & Getting Results If you created two Activities A and B, you can start B from A, and have B return some result to A instead of startactivity(intent) call startactivityforresult(intent, int)
70 Starting Activities & Getting Results private int MY_CODE = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void startsecondactivity(view v) { Intent intent = new Intent(A.this, B.class); startactivityforresult(intent, MY_CODE);
71 Starting Activities & Getting Results private int MY_CODE = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); This code is for Activity A public void startsecondactivity(view v) { Intent intent = new Intent(A.this, B.class); startactivityforresult(intent, MY_CODE);
72 Starting Activities & Getting Results private int MY_CODE = 29; Some number that you want to use to identify your request. #29 is nothing special public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void startsecondactivity(view v) { Intent intent = new Intent(A.this, B.class); startactivityforresult(intent, MY_CODE);
73 Starting Activities & Getting Results private int MY_CODE = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void startsecondactivity(view v) { Intent intent = new Intent(A.this, B.class); startactivityforresult(intent, MY_CODE); I added a button to the XML and set the android:onclick attribute to this method
74 Starting Activities & Getting Results private int MY_CODE = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); We have seen this before public void startsecondactivity(view v) { Intent intent = new Intent(A.this, B.class); startactivityforresult(intent, MY_CODE);
75 Starting Activities & Getting Results private int MY_CODE = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void startsecondactivity(view v) { Intent intent = new Intent(A.this, B.class); startactivityforresult(intent, MY_CODE); Instead of startactivity(intent), we call startactivityforresult and give it the intent along with our "special" request code.
76 Starting Activities & Getting Results protected void onactivityresult(int requestcode, { int resultcode, Intent data) if(requestcode == MY_CODE) { if(resultcode == RESULT_OK) { // result is OK, add code here We also need to add this method to Activity A, to react to when the result has been returned from Activity B.
77 Starting Activities & Getting Results public class B extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.second); public void finishme(view v) { setresult(activity.result_ok, null); finish();
78 Starting Activities & Getting Results public class B extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.second); public void finishme(view v) { This code is for Activity B setresult(activity.result_ok, null); finish();
79 Starting Activities & Getting Results public class B extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.second); public void finishme(view v) { setresult(activity.result_ok, null); finish(); Assuming there's a Button with android:onclick="finishme"
80 Starting Activities & Getting Results public class B extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.second); public void finishme(view v) { setresult(activity.result_ok, null); finish(); Set the result of this Activity to OK. The second argument is an Intent, but we'll go in to this another time.
81 Starting Activities & Getting Results public class B extends Activity public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.second); public void finishme(view v) { setresult(activity.result_ok, null); finish(); Finish this Activity B, which will lead to ondestroy() being called, and Activity A becoming active. onactivityresult() in A will then be called.
82 Starting Activities & Getting Results See StartActivityForResult Example
83 Starting Activities & Getting Results As another example, let's call upon an existing Android Activity for a result
84 Starting Activities & Getting Results static final int PICK_REQUEST = 1337; Here's our request code public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void pickcontact(view v) { Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startactivityforresult(intent, PICK_REQUEST); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
85 Starting Activities & Getting Results static final int PICK_REQUEST = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); Tied to a Button with public void pickcontact(view v) { android:onclick="pickcontact" Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startactivityforresult(intent, PICK_REQUEST); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
86 Starting Activities & Getting Results static final int PICK_REQUEST = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); We use a different constructor for the Intent this time public void pickcontact(view v) { Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startactivityforresult(intent, PICK_REQUEST); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
87 Starting Activities & Getting Results static final int PICK_REQUEST = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); These two arguments must mean something together, they don't always do! public void pickcontact(view v) { Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startactivityforresult(intent, PICK_REQUEST); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
88 Starting Activities & Getting Results static final int PICK_REQUEST = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); There should be an Activity that recognizes this Intent public void pickcontact(view v) { Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startactivityforresult(intent, PICK_REQUEST); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
89 Starting Activities & Getting Results static final int PICK_REQUEST = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); If none exists, you will probably get Force Close public void pickcontact(view v) { Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startactivityforresult(intent, PICK_REQUEST); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
90 Starting Activities & Getting Results static final int PICK_REQUEST = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void pickcontact(view v) { Nothing new here Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); startactivityforresult(intent, PICK_REQUEST); protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
91 Starting Activities & Getting Results static final int PICK_REQUEST = public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); public void pickcontact(view v) { That starts Activity B. When Intent intent = new Intent(Intent.ACTION_PICK, Phone.CONTENT_URI); Activity B has returned, the startactivityforresult(intent, result PICK_REQUEST); will be returned to this callback function protected void onactivityresult(int requestcode, int resultcode, Intent data) { if (requestcode == PICK_REQUEST) { if (resultcode == RESULT_OK) { /* result is OK! */
92 Starting Activities & Getting Results See PickContacts Example
93 Understanding Implicit Intents Implicit Intents Specify the action that should be performed and optionally the URI which should be used in conjunction with the action Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse( )); The Android system searches for all the components that are registered to handle this specific action If the system only finds one component then it will launch that automatically Else it will show a dialog that will give the user the option of selecting the one they prefer If none is found, you may get an Exception
94 Understanding Implicit Intents How do you know which Intent Action to specify for a given Uri?
95 Understanding Implicit Intents There are three rules, all of which must be true for a given activity to be eligible for a given intent 1. The activity must support the specified action 2. The activity must support the stated MIME type (if supplied) 3. The activity must support all of the categories named in the intent The upshot is that you want to make your intents specific enough to find the right receiver(s), and no more specific than that.
96 Understanding Implicit Intents Let's take a look at what happens when when the Home key is pressed...
97 Understanding Implicit Intents Open LogCat Click the + button to add a new filter Enter the following Filter Name: ActivityManager Log Tag: ActivityManager Now press the Home key on your device For the Tag Column, look for ActivityManager For the Text Column, look for anything beginning with "Starting: Intent..." The last one should be the Intent that was used to launch the home screen Mouseover that row, and you should see values for the following act, which is the action - android.intent.action.main cat, which is the category - android.intent.category.home in this case, there is no data, but sometimes there is Note the action and category
98 Understanding Implicit Intents Can we create our own Home Screen app? Create a new project Open AndroidManifest.xml Add a new intent-filter to your Activity The action should match the one you found in LogCat So should the category In addition, add the DEFAULT category <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.home" /> <category android:name="android.intent.category.default" /> </intent-filter>
99 Understanding Implicit Intents Now press the Home key... For a nicer effect, make your Activity full-screen by adding this to the <activity> tag in the manifest file android:theme="@android:style/theme.notitlebar.fullscreen" JUST DO NOT TO MAKE YOUR NEW HOME SCREEN DEFAULT IF YOU ADD THE FULLSCREEN FEATURE
100 Understanding Implicit Intents See HomeScreen Example
101 Understanding Implicit Intents It's not too difficult to figure out the Java code for the same Intent: <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.home" /> <category android:name="android.intent.category.default" /> </intent-filter> or IntentFilter myfilter = new IntentFilter(Intent.ACTION_MAIN); myfilter.addcategory(intent.category_home);
102 Understanding Implicit Intents If you make your Intent Filters Too vague Too specific It won't match what you expect it to. Try to make your Intent Filters precise!
103 Understanding Implicit Intents Now that you know a little bit about Intents, try to figure this out. If you developed a Music Player, how would you go about allowing the user to choose your Music Player after clicking on a music file on his or her phone?
104 References The Busy Coder's Guide to Android Development - Mark Murphy Android Developers The Mobile Lab at Florida State University
ELET4133: 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 informationregister/unregister for Intent to be activated if device is within a specific distance of of given lat/long
stolen from: http://developer.android.com/guide/topics/sensors/index.html Locations and Maps Build using android.location package and google maps libraries Main component to talk to is LocationManager
More informationAndroid Help. Section 8. Eric Xiao
Android Help Section 8 Eric Xiao The Midterm That happened Any residual questions? New Assignment! Make a low-fi prototype Must be interactive Use balsamiq or paper Test it with users 3 tasks Test task
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 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 informationUpcoming Assignments Quiz today Web Ad due Monday, February 22 Lab 5 due Wednesday, February 24 Alpha Version due Friday, February 26
Upcoming Assignments Quiz today Web Ad due Monday, February 22 Lab 5 due Wednesday, February 24 Alpha Version due Friday, February 26 To be reviewed by a few class members Usability study by CPE 484 students
More informationAndroid Apps Development for Mobile Game Lesson 5
Workshop 1. Create a simple Environment Sensors (Page 1 6) Pressure Sensor Ambient Temperature Sensor Light Sensor Relative Humidity Sensor 2. Create a simple Position Sensors (Page 7 8) Proximity Sensor
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 information1. Location Services. 1.1 GPS Location. 1. Create the Android application with the following attributes. Application Name: MyLocation
1. Location Services 1.1 GPS Location 1. Create the Android application with the following attributes. Application Name: MyLocation Project Name: Package Name: MyLocation com.example.mylocation 2. Put
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 informationMobile Application (Design and) Development
Mobile Application (Design and) Development 11 th class Prof. Stephen Intille s.intille@neu.edu Northeastern University 1 Q&A Northeastern University 2 Today Services Location and sensing Design paper
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 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 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 informationAn Overview of the Android Programming
ID2212 Network Programming with Java Lecture 14 An Overview of the Android Programming Hooman Peiro Sajjad KTH/ICT/SCS HT 2016 References http://developer.android.com/training/index.html Developing Android
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 informationPress project on the left toolbar if it doesn t show an overview of the app yet.
#3 Setting up the permissions needed to allow the app to use GPS. Okay! Press project on the left toolbar if it doesn t show an overview of the app yet. In this project plane, we will navigate to the manifests
More informationDesigning Apps Using The WebView Control
28 Designing Apps Using The Control Victor Matos Cleveland State University Notes are based on: Android Developers http://developer.android.com/index.html The Busy Coder's Guide to Advanced Android Development
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 informationAndroid Security Lab WS 2013/14 Lab 2: Android Permission System
Saarland University Information Security & Cryptography Group Prof. Dr. Michael Backes saarland university computer science Android Security Lab WS 2013/14 M.Sc. Sven Bugiel Version 1.2 (November 12, 2013)
More informationGetting Started ArcGIS Runtime SDK for Android. Andy
Getting Started ArcGIS Runtime SDK for Android Andy Gup @agup Agenda Introduction Runtime SDK - Tools and features Maps & Layers Tasks Editing GPS Offline Capabilities Summary My contact info Andy Gup,
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 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 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 informationTerms: MediaPlayer, VideoView, MediaController,
Terms: MediaPlayer, VideoView, MediaController, Sisoft Technologies Pvt Ltd SRC E7, Shipra Riviera Bazar, Gyan Khand-3, Indirapuram, Ghaziabad Website: www.sisoft.in Email:info@sisoft.in Phone: +91-9999-283-283
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 informationSpring Lecture 9 Lecturer: Omid Jafarinezhad
Mobile Programming Sharif University of Technology Spring 2016 - Lecture 9 Lecturer: Omid Jafarinezhad Sensors Overview Most Android-powered devices have built-in sensors that measure motion, orientation,
More informationLab 5 Periodic Task Scheduling
Lab 5 Periodic Task Scheduling Scheduling a periodic task in Android is difficult as it goes against the philosophy of keeping an application active only while the user is interacting with it. You are
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 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 informationCS 234/334 Lab 1: Android Jump Start
CS 234/334 Lab 1: Android Jump Start Distributed: January 7, 2014 Due: Friday, January 10 or Monday, January 13 (in-person check off in Mobile Lab, Ry 167). No late assignments. Introduction The goal of
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 informationIntents. 18 December 2018 Lecture Dec 2018 SE 435: Development in the Android Environment 1
Intents 18 December 2018 Lecture 4 18 Dec 2018 SE 435: Development in the Android Environment 1 Topics for Today Building an Intent Explicit Implicit Other features: Data Result Sources: developer.android.com
More informationAndroid for Ubiquitous Computing Researchers. Andrew Rice University of Cambridge 17-Sep-2011
Android for Ubiquitous Computing Researchers Andrew Rice University of Cambridge 17-Sep-2011 Getting started Website for the tutorial: http://www.cl.cam.ac.uk/~acr31/ubicomp/ Contains links to downloads
More informationMobile Programming Lecture 3. Resources, Selection, Activities, Intents
Mobile Programming Lecture 3 Resources, Selection, Activities, Intents Lecture 2 Review What widget would you use to allow the user to enter a yes/no value a range of values from 1 to 100 What's the benefit
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 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 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 informationDeveloping Android Applications
Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 21 October 2015 Android Lab 02 Advanced Android Features 2 Class Plan UI Elements Activities Intents Data Transfer
More information8/30/15 MOBILE COMPUTING. CSE 40814/60814 Fall How many of you. have implemented a command-line user interface?
MOBILE COMPUTING CSE 40814/60814 Fall 2015 How many of you have implemented a command-line user interface? 1 How many of you have implemented a graphical user interface? HTML/CSS Java Swing.NET Framework
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 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 information10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics
Chapter 10 Speech Recognition 10.1 Introduction Speech recognition (SR) by machine, which translates spoken words into text has been a goal of research for more than six decades. It is also known as automatic
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 informationExercise 1: First Android App
Exercise 1: First Android App Start a New Android Studio App Open Android Studio. Click on Start a new Android Studio project. For Application name enter First App. Keep other fields as default and click
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 informationIntroduction to Android Multimedia
Introduction to Android Multimedia CS 436 Software Development on Mobile By Dr.Paween Khoenkaw Android Intent Intent,Intent-filter What is Intent? -Intent is a message sent from one program to another
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 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 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 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 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 informationServices Broadcast Receivers Permissions
Services Broadcast Receivers Permissions Runs in the background Extends Service Java class Not necessarily connected to the user s visual interface Music player working in foreground User wants read email
More informationServices are software components designed specifically to perform long background operations.
SERVICES Service Services are software components designed specifically to perform long background operations. such as downloading a file over an internet connection or streaming music to the user, but
More informationServices & Interprocess Communication (IPC) CS 282 Principles of Operating Systems II Systems Programming for Android
Services & Interprocess Communication (IPC) CS 282 Principles of Operating Systems II Systems Programming for Android A Service is an application component that can perform longrunning operations in the
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 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 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 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 informationVoice Control SDK. Vuzix M100 Developer SDK. Developer Documentation. Ron DiNapoli Vuzix Corporation Created: July 22, 2015 Last Update: July 22, 2015
Voice Control SDK Vuzix M100 Developer SDK Ron DiNapoli Vuzix Corporation Created: July 22, 2015 Last Update: July 22, 2015 Developer Documentation Introduction The Vuzix Voice Control SDK allows you to
More informationInternet of Things Sensors - Part 1 Location Services
Internet of Things Sensors - Part 1 Location Services Aveek Dutta Assistant Professor Department of Computer Engineering University at Albany SUNY e-mail: adutta@albany.edu http://www.albany.edu/faculty/adutta
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 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 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 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 informationUsing Libraries, Text-to-Speech, Camera. Lecture 12
Using Libraries, Text-to-Speech, Camera Lecture 12 Libraries Many Android developers have produced useful libraries. There is a Maven repository to store various libraries This makes it easy to add them
More informationMidterm Examination. CSCE 4623 (Fall 2017) October 20, 2017
Midterm Examination CSCE 4623 (Fall 2017) Name: UA ID: October 20, 2017 Instructions: 1. You have 50 minutes to complete the exam. The exam is closed note and closed book. No material is allowed with you
More informationIntroduction To Android
Introduction To Android Mobile Technologies Symbian OS ios BlackBerry OS Windows Android Introduction to Android Android is an operating system for mobile devices such as smart phones and tablet computers.
More informationMobila applikationer och trådlösa nät
Mobila applikationer och trådlösa nät HI1033 Lecture 8 Today s topics Location Based Services Google Maps API MultiMedia Location Based Services LocationManager provides access to location based services
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 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 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 informationProduced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar
Design Patterns MSc in Computer Science Produced by Eamonn de Leastar (edeleastar@wit.ie)! Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
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 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 informationLoca%on Support in Android. COMP 355 (Muppala) Location Services and Maps 1
Loca%on Support in Android COMP 355 (Muppala) Location Services and Maps 1 Loca%on Services in Android Loca%on capabili%es for applica%ons supported through the classes in android.loca%on package and Google
More informationMobile Programming Lecture 2. Layouts, Widgets, Toasts, and Event Handling
Mobile Programming Lecture 2 Layouts, Widgets, Toasts, and Event Handling Lecture 1 Review How to edit XML files in Android Studio? What holds all elements (Views) that appear to the user in an Activity?
More informationInternal 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 informationApp Development for Android. Prabhaker Matet
App Development for Android Prabhaker Matet Development Tools (Android) Java Java is the same. But, not all libs are included. Unused: Swing, AWT, SWT, lcdui Android Studio (includes Intellij IDEA) Android
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 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 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 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 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 informationLab 1: Getting Started With Android Programming
Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Eng. Jehad Aldahdooh Mobile Computing Android Lab Lab 1: Getting Started With Android Programming To create a new Android Project
More informationLifecycle Callbacks and Intents
SE 435: Development in the Android Environment Recitations 2 3 Semester 1 5779 4 Dec - 11 Dec 2018 Lifecycle Callbacks and Intents In this recitation we ll prepare a mockup tool which demonstrates the
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 informationApp Development for Smart Devices. Lec #8: Android Sensors
App Development for Smart Devices CS 495/595 - Fall 2011 Lec #8: Android Sensors Tamer Nadeem Dept. of Computer Science Some slides adapted from Stephen Intille Objective Android Sensors Sensor Manager
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 informationAndroid Programming Lecture 7 9/23/2011
Android Programming Lecture 7 9/23/2011 Multiple Activities So far, projects limited to one Activity Next step: Intra-application communication Having multiple activities within own application Inter-application
More informationLECTURE 12 BROADCAST RECEIVERS
MOBILE APPLICATION DEVELOPMENT LECTURE 12 BROADCAST RECEIVERS IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM Application Building Blocks Android Component Activity UI Component Typically Corresponding
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 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 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 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 informationAndroid Programmierung leichtgemacht. Lars Vogel
Android Programmierung leichtgemacht Lars Vogel Twitter: @vogella Lars Vogel Arbeitet als unabhängiger Eclipse und Android Berater und Trainer Arbeit zusätzlichen für SAP AG als Product Owner in einem
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 informationCreate new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.
Hello World Lab Objectives: Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.xml What to Turn in: The lab evaluation
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 informationAndroid Programming Lecture 2 9/7/2011
Android Programming Lecture 2 9/7/2011 Creating a first app 1. Create a new Android project (a collection of source code and resources for the app) from the Eclipse file menu 2. Choose a project name (can
More information