Internal Services. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Size: px
Start display at page:

Download "Internal Services. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr."

Transcription

1 Internal Services CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1

2 Internal Services Communication: , SMS and telephony Audio and video: Record and playback Sensors: Accelerometer, light, magnetic, ambient temperature 2

3 Sending Java public void sendscoresvia () { Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.putextra( android.content.intent.extra_subject, "Look at my AWESOME TicTacToe Score!"); // Can also fill To: using putextra(..., EXTRA_ ) intent.settype("plain/text"); intent.putextra(android.content.intent.extra_text, firstplayername + " score is " + scoreplayerone + " and " + secondplayername + " score is " + scoreplayertwo); startactivity( intent); How to send programmatically: (or search online) 3

4 Sending Kotlin fun sendscoresvia () { val intent = Intent(Intent.ACTION_SEND) intent.putextra(intent.extra_subject, "Look at my AWESOME TicTacToe Score!") intent.type = "plain/text" intent.putextra(intent.extra_text, mfirstplayername + " score is " + mscoreplayerone + " and " + msecondplayername + " score is " + mscoreplayertwo) startactivity( intent) 4

5 SMS: Java public void sendscoresviasms() { Intent SMSIntent = new Intent(Intent.ACTION_VIEW); SMSIntent.putExtra("sms_body", "Look at my AWESOME TicTacToe Score!" + firstplayername + " score is " + scoreplayerone + " and " + secondplayername + " score is " + scoreplayertwo); SMSIntent.setType("vnd.android-dir/mms-sms"); startactivity(smsintent); Can also use SMS class; see: You need <uses-permission android:name= android.permission.send_sms /> 5

6 SMS: Kotlin fun sendscoresviasms() { val SMSIntent = Intent(Intent.ACTION_VIEW) SMSIntent.putExtra("sms_body", "Look at my AWESOME TicTacToe Score!" + mfirstplayername + " score is " + mscoreplayerone + " and " + msecondplayername + " score is " + mscoreplayertwo) SMSIntent.type = "vnd.android-dir/mms-sms" startactivity(smsintent) 6

7 Telephony: Java public void calltictactoehelp() { Intent phoneintent = new Intent(Intent.ACTION_DIAL); String phonenumber = " "; // TIC TAC HELP String uri = "tel:" + phonenumber.trim(); phoneintent.setdata(uri.parse(uri)); startactivity(phoneintent); Needs: <uses-permission android:name="android.permission.call_phone"/> 7

8 Telephony: Kotlin fun calltictactoehelp() { val phoneintent = Intent(Intent.ACTION_DIAL) val phonenumber = " " // TIC TAC HELP val uri = "tel:" + phonenumber.trim { it <= ' ' phoneintent.data = Uri.parse(uri) startactivity(phoneintent) 8

9 1. 2. Playing Audio Example: Setup <?xml version="1.0" encoding="utf-8"?> <LinearLayout... > <Button... android:text="start Audio"/> <Button... android:text="stop Audio /> <Button... android:text="record Audio"/> <Button... android:text="exit" /> </LinearLayout> View device file system in Android Studio. Transfer files via your computer s OS (ensure drivers are installed first). Media file is sampleaudio.mp3 in external storage music directory (varies among devices). Next slides show AudioFragment code (Java and Kotlin). 9

10 // AudioFragment.java private String maudiofilepath = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_MUSIC).getPath() + File.separator + "sample_audio.mp3"; private Intent mrecordaudiointent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION) private Uri maudiofileuri; public void onclick(view view) { switch (view.getid()) { case R.id.buttonAudioStart: if (!mstarted) { Intent musicintent = new Intent(getActivity().getApplicationContext(), MediaPlaybackService.class); musicintent.putextra("uristring", maudiofileuri.tostring()); 1 Log.d(TAG, "URI: " + maudiofileuri.tostring()); getactivity().startservice(musicintent); mstarted = true; break; case R.id.buttonAudioStop: getactivity().stopservice(new Intent(getActivity().getApplicationContext(), MediaPlaybackService.class)); mstarted = false; break; case R.id.buttonAudioRecord: 2 startactivityforresult(mrecordaudiointent, AUDIO_CAPTURED); break; case R.id.buttonAudioExit: getactivity().finish(); break; public void onactivityresult(int requestcode, int resultcode, Intent data) { if (resultcode == RESULT_OK && requestcode == AUDIO_CAPTURED) { maudiofileuri = data.getdata(); 10 3

11 // AudioFragment.kt private val maudiofilepath = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_MUSIC).path + File.separator + "sample_audio.mp3" private lateinit var maudiofileuri: Uri private val mrecordaudiointent = Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION) override fun onclick(view: View) { when (view.id) { R.id.buttonAudioStart -> if (!mstarted) { val musicintent = Intent(activity.applicationContext, MediaPlaybackService::class.java) musicintent.putextra("uristring", maudiofileuri.tostring()) Log.d(TAG, "URI: " + maudiofileuri.tostring()) activity.startservice(musicintent) mstarted = true R.id.buttonAudioStop -> { activity.stopservice(intent(activity.applicationcontext, MediaPlaybackService::class.java)) mstarted = false R.id.buttonAudioRecord -> startactivityforresult(mrecordaudiointent, AUDIO_CAPTURED) R.id.buttonAudioExit -> activity.finish() override fun onactivityresult(requestcode: Int, resultcode: Int, data: Intent?) { if (resultcode == RESULT_OK && requestcode == AUDIO_CAPTURED) { if (data!= null) { maudiofileuri = data.data

12 reset() Idle setdatasource() Preparing prepareasync() Initialized OnPreparedListener. onprepared() prepare() seekto() Prepared Media prepareasync() prepare() stop() start() looping == true && playback completes Player seekto(), start() Started start() States stop() pause() stop() seekto(), pause() Stopped stop() looping == false and oncompletion() invoked on OnCompletionListener Paused stop() start() (from beginning) Playback Completed seekto() Source: 12

13 Playing Audio: Service: Java <service android:enabled="true android:name=".mediaplaybackservice /> // MediaPlayerService.java public class MediaPlaybackService extends Service { MediaPlayer public IBinder onbind(intent intent) { return public void oncreate() { player = MediaPlayer.create(this, R.raw.sample_audio); public int onstartcommand(intent intent, int flags, int startid) { super.onstartcommand(intent, flags, startid); Bundle extras = intent.getextras(); if (extras!= null) { String audiofileuristring = extras.getstring("uristring"); Uri audiofileuri = Uri.parse(audioFileURIString); try { player.reset(); player.setdatasource(this.getapplicationcontext(), audiofileuri); player.prepare(); player.start(); catch (Exception e) { e.printstacktrace(); return public void ondestroy() { player.stop(); 13

14 Playing Audio: Service: Kotlin <service android:enabled="true android:name=".mediaplaybackservice /> // MediaPlayerService.kt class MediaPlaybackService : Service() { internal lateinit var player: MediaPlayer override fun onbind(intent: Intent): IBinder? { return null override fun oncreate() { player = MediaPlayer.create(this, R.raw.sample_audio) player.apply { islooping = true override fun onstartcommand(intent: Intent, flags: Int, startid: Int): Int { super.onstartcommand(intent, flags, startid) val extras = intent.extras if (extras!= null) { val audiofileuristring = extras.getstring("uristring") val audiofileuri = Uri.parse(audioFileURIString) try { player.reset() player.setdatasource(this.applicationcontext, audiofileuri) player.prepare() player.start() catch (e: Exception) { e.printstacktrace() return Service.START_STICKY override fun ondestroy() { player.stop() 14

15 Handling Video Using VideoView <?xml version="1.0" encoding="utf-8"?> <LinearLayout... > <VideoView android:layout_height="175dip" android:layout_width="match_parent" android:layout_gravity="center" /> <Button... android:text="start Video"/> <Button... android:text="stop Video /> <Button... android:text="record Video"/> <Button... android:text="exit" /> </LinearLayout> 15

16 Handling Video: // VideoFragment.java public class VideoFragment extends Fragment Java (1) implements View.OnClickListener { private Button mbuttonstart, mbuttonstop, mbuttonrecord; private VideoView mvideoview = null; private Uri mvideofileuri = null; private Intent mrecordvideointent = new public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { View v = inflater.inflate(r.layout.fragment_video, container, false); mvideoview = (VideoView) v.findviewbyid(r.id.videoview); mbuttonstart = (Button) v.findviewbyid(r.id.buttonvideostart); // Set onclicklistener(this) mbuttonstop = (Button) v.findviewbyid(r.id.buttonvideostop); // Set onclicklistener(this) mbuttonrecord = (Button) v.findviewbyid(r.id.buttonvideorecord); // Set onclicklistener(this) Button btnexit = (Button) v.findviewbyid(r.id.buttonvideoexit); // Set onclicklistener(this) String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).getPath() + File.separator + "sample_video.mp4"; File videofile = new File(path); if (videofile.exists()) { mvideofileuri = Uri.fromFile(videoFile); else { // Video file doesn't exist, so load sample video from resources. String videoresourcename = "android.resource://" + getactivity().getpackagename() + File.separator + R.raw.sample_video; mvideofileuri = Uri.parse(videoResourceName); // Guard against no audio recorder app (disable the "record" button). PackageManager packagemanager = getactivity().getpackagemanager(); if (packagemanager.resolveactivity(mrecordvideointent, PackageManager.MATCH_DEFAULT_ONLY) == null) { mbuttonrecord.setenabled(false); return v; 16

17 // VideoFragment.java (continued) Handling Video: Java public void onclick(view view) { switch (view.getid()) { case R.id.buttonVideoStart: // Load and start the movie mvideoview.setvideouri(mvideofileuri); mvideoview.start(); break; case R.id.buttonVideoRecord: startactivityforresult(mrecordvideointent, VIDEO_CAPTURED); break; case R.id.buttonVideoStop: mvideoview.stopplayback(); break; case R.id.buttonVideoExit: getactivity().finish(); break; public void onactivityresult(int requestcode, int resultcode, Intent data) { if (resultcode == RESULT_OK && requestcode == VIDEO_CAPTURED) { mvideofileuri = data.getdata(); 17

18 // AudioFragment.kt class VideoFragment : Fragment(), View.OnClickListener { private lateinit var mbuttonstart: Button private lateinit var mbuttonstop: Button private lateinit var mbuttonrecord: Button private lateinit var mvideoview: VideoView private var mvideofileuri: Uri? = null private val mrecordvideointent = Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE) override fun oncreateview(inflater: LayoutInflater, container: ViewGroup?, savedinstancestate: Bundle?): View? { val v = inflater.inflate(r.layout.fragment_video, container, false) mvideoview = v.findviewbyid<videoview>(r.id.videoview) mbuttonstart = v.findviewbyid<button>(r.id.buttonvideostart) // Set onclickli mbuttonstop = v.findviewbyid<button>(r.id.buttonvideostop) mbuttonrecord = v.findviewbyid<button>(r.id.buttonvideorecord) val btnexit = v.findviewbyid<button>(r.id.buttonvideoexit) val path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES).path + File.separator + "sample_video.mp4" val videofile = File(path) if (videofile.exists()) { mvideofileuri = Uri.fromFile(videoFile) else { // Video file doesn't exist, so load sample video from resources. val videoresourcename = "android.resource://" + activity.packagename + File.separator + R.raw.sample_video mvideofileuri = Uri.parse(videoResourceName) Handling Video: Kotlin (1) // Guard against no audio recorder app (disable the "record" button). val packagemanager = activity.packagemanager if (packagemanager.resolveactivity(mrecordvideointent, PackageManager.MATCH_DEFAULT_ONLY) == null) { mbuttonrecord.isenabled = false return v 18

19 Handling Video: Kotlin (2) override fun onclick(view: View) { when (view.id) { R.id.buttonVideoStart -> { // Load and start the movie mvideoview.setvideouri(mvideofileuri) mvideoview.start() R.id.buttonVideoRecord -> startactivityforresult(mrecordvideointent, VIDEO_CAPTURED) R.id.buttonVideoStop -> mvideoview.stopplayback() R.id.buttonVideoExit -> activity.finish() override fun onactivityresult(requestcode: Int, resultcode: Int, data: Intent?) { if (resultcode == RESULT_OK && requestcode == VIDEO_CAPTURED) { if (data!= null) { mvideofileuri = data.data 19

20 Handling Images: ImageView <?xml version="1.0" encoding="utf-8"?> <LinearLayout... > <ImageView android:layout_height="175dip" android:layout_width="match_parent" android:layout_gravity="center" /> <Button... android:text="show Image"/> <Button... android:text="take Picture"/> <Button... android:text="exit" /> </LinearLayout> 20

21 Handling Images: Java (1) // ImageFragment.java public class ImagesFragment extends Fragment implements View.OnClickListener { private ImageView imageview = null; private static Uri imagefileuri; private String imagefilepath = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES).getPath() + File.separator + "other_image.png"; private Bitmap imagebitmap = null; private Intent mcaptureimageintent = new Intent( public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { View v = inflater.inflate(r.layout.fragment_images, container, false); imageview = (ImageView) v.findviewbyid(r.id.imageview); Button buttonshow = (Button) v.findviewbyid(r.id.buttonimageshow); Button buttoncapture = (Button) v.findviewbyid(r.id.buttonimagecapture); Button buttonexit = (Button) v.findviewbyid(r.id.buttonimageexit); // Set up onclicklistener(this) for the buttons return v; 21

22 Handling Images: Java(2) // ImageFragment.java public void onclick(view view) { switch(view.getid()) { case R.id.buttonImageShow: File imagefile = new File(imageFilePath); if (imagefile.exists()) { imagebitmap = BitmapFactory.decodeFile(imageFilePath); imageview.setimagebitmap(imagebitmap); else { // File doesn't exist, so load a sample SVG image. imageview.setlayertype(view.layer_type_software, null); imageview.setimageresource(r.drawable.ic_scoreboard); break; case R.id.buttonImageCapture: startactivityforresult(mcaptureimageintent, IMAGE_CAPTURED); break; case R.id.buttonImageExit: getactivity().finish(); break; 22

23 Handling Images: Java (3) // ImageFragment.java (continued) public void onactivityresult(int requestcode, int resultcode, Intent cameraintent) { if (resultcode == RESULT_OK && requestcode == IMAGE_CAPTURED) { Bundle extras = cameraintent.getextras(); if (extras!= null) { imagebitmap = (Bitmap) extras.get("data"); imageview.setimagebitmap(imagebitmap); Memory management is critical for Bitmaps! Consider using an LRU cache or library such as Glide ( to handle them. See for more info. See also: 23

24 Handling Images: Kotlin (1) // ImagesFragment.kt class ImagesFragment : Fragment(), View.OnClickListener { private lateinit var imageview: ImageView private val imagefilepath = Environment.getExternalStoragePublicDirectory( Environment.DIRECTORY_PICTURES).path + File.separator + "other_image.png" private lateinit var imagebitmap: Bitmap private lateinit var imagefileuri: Uri private val mcaptureimageintent = Intent( android.provider.mediastore.action_image_capture) override fun oncreateview(inflater: LayoutInflater, container: ViewGroup?, savedinstancestate: Bundle?): View? { val v = inflater.inflate(r.layout.fragment_images, container, false) imageview = v.findviewbyid<imageview>(r.id.imageview) as ImageView val buttonshow = v.findviewbyid<button>(r.id.buttonimageshow) as Button val buttoncapture = v.findviewbyid<button>(r.id.buttonimagecapture) as Button val buttonexit = v.findviewbyid<button>(r.id.buttonimageexit) as Button // Set onclicklistener(this) for each Button return v //... 24

25 Handling Images: Kotlin (2) // ImagesFragment.kt (continued) override fun onclick(view: View) { when (view.id) { R.id.buttonImageShow -> { val imagefile = File(imageFilePath) if (imagefile.exists()) { imagebitmap = BitmapFactory.decodeFile(imageFilePath) imageview.setimagebitmap(imagebitmap) else { // File doesn't exist, so load a sample SVG image. // Disable hardware acceleration for SVGs imageview.setlayertype(view.layer_type_software, null) imageview.setimageresource(r.drawable.ic_scoreboard) R.id.buttonImageCapture -> startactivityforresult(mcaptureimageintent, IMAGE_CAPTURED) R.id.buttonImageExit -> activity.finish() 25

26 Handling Images: Kotlin (3) // ImagesFragment.kt (continued) override fun onactivityresult(requestcode: Int, resultcode: Int, cameraintent: Intent?) { if (resultcode == RESULT_OK && requestcode == IMAGE_CAPTURED) { val extras = cameraintent?.extras if (extras!= null) { imagebitmap = extras.get("data") as Bitmap imageview.setimagebitmap(imagebitmap) 26

27 Sensors Uses: Provide contextual and environmental data to app Tailor app to environment, how people are using devices Example Tic-Tac-Toe files: SensorsFragment class fragment_sensors.xml, list_item_sensor.xml Issues: Noisy sensor data on real-world devices Best tested on real devices. To simulate sensors on the emulator see: Inexpensive real devices: Moto E (4th gen.), Moto G (5th gen.). See: Amazon, ebay Type Motion Environmental Miscellaneous Examples Accelerometer, gyroscope Light, temperature, humidity, barometric pressure Camera, microphone, fingerprint, infrared 27

28 Displaying Sensors Display all device sensors (and their info) in a RecyclerView RecyclerView: displays (possibly large) dynamic list/grid of items with limited memory footprint More info: guide/topics/ui/layout/recycler view.html Views 28

29 RecyclerView Workflow Source: Figs , Bill Phillips, Chris Stewart, and Kristin Marsicano, Android Programming: The Big Nerd Ranch Guide, 3rd ed.,

30 Listing Available Sensors: Java private RecyclerView msensorrecyclerview; private SensorAdapter msensoradapter; private SensorManager msensormanager; private List<Sensor> public View oncreateview(layoutinflater inflater, ViewGroup container, Bundle savedinstancestate) { View v = inflater.inflate(r.layout.fragment_sensor_list, container, false); msensorrecyclerview = (RecyclerView) v.findviewbyid(r.id.sensor_recycler_view); msensorrecyclerview.setlayoutmanager(new LinearLayoutManager(getActivity())); msensormanager = (SensorManager) getactivity().getsystemservice(sensor_service); if (msensormanager!= null) { msensorlist = msensormanager.getsensorlist(sensor.type_all); madapter = new SensorAdapter(mSensorList); // Adapts sensor info to msensorrecyclerview.setadapter(madapter); // RecyclerView return v; 30

31 Listing Available Sensors: Kotlin private lateinit var msensorrecyclerview: RecyclerView private lateinit var madapter: SensorAdapter private lateinit var msensormanager: SensorManager private lateinit var msensorlist: List<Sensor> private var lastsensorvalues = Hashtable<String, FloatArray>() override fun oncreateview(inflater: LayoutInflater, container: ViewGroup?, savedinstancestate: Bundle?): View? { val v = inflater.inflate(r.layout.fragment_sensor_list, container, false) msensorrecyclerview = v.findviewbyid<recyclerview>(r.id.sensor_recycler_view) msensorrecyclerview.layoutmanager = LinearLayoutManager(activity) msensormanager = activity.getsystemservice(sensor_service) as SensorManager msensorlist = msensormanager.getsensorlist(sensor.type_all) madapter = SensorAdapter(mSensorList) // Adapts msensorrecyclerview.adapter = madapter return v 31

32 Sensor Holder Java private class SensorHolder extends RecyclerView.ViewHolder { private Sensor msensor; private String mdescriptionstr; private TextView msensorinfotextview; public SensorHolder(LayoutInflater inflater, ViewGroup parent) { super(inflater.inflate( R.layout.list_item_sensor, parent, false)); msensorinfotextview = (TextView) itemview.findviewbyid(r.id.sensor_data); public void bind(sensor sensor) { msensor = sensor; mdescriptionstr = getsensordescription( sensor); msensorinfotextview.settext( mdescriptionstr); Kotlin private inner class SensorHolder( inflater: LayoutInflater, parent: ViewGroup) : RecyclerView.ViewHolder( inflater.inflate(r.layout.list_item_sensor, parent, false)) { private lateinit var msensor: Sensor private lateinit var mdescriptionstr: String private val msensorinfotextview: TextView init { msensorinfotextview = itemview.findviewbyid<textview>( R.id.sensor_data) fun bind(sensor: Sensor) { msensor = sensor mdescriptionstr = getsensordescription( sensor) msensorinfotextview.text = mdescriptionstr 32

33 Sensor Adapter Java private class SensorAdapter extends RecyclerView.Adapter<SensorHolder> { private List<Sensor> msensorlist; public SensorAdapter(List<Sensor> sensorlist) { msensorlist = public SensorHolder oncreateviewholder( ViewGroup parent, int viewtype) { LayoutInflater inflater = LayoutInflater.from( getactivity()); return new SensorHolder(inflater, parent); Kotlin private inner class SensorAdapter( private val msensorlist: List<Sensor>) : RecyclerView.Adapter<SensorHolder>() { override fun oncreateviewholder( parent: ViewGroup, viewtype: Int): SensorHolder { val inflater = LayoutInflater.from( activity) return SensorHolder(inflater, public void onbindviewholder(sensorholder holder, int position) { Sensor sensor = SensorsFragment.this.mSensorList.get(position); String sensordescription = getsensordescription( sensor); public int getitemcount() { return msensorlist.size(); override fun onbindviewholder( holder: SensorHolder, position: Int) { val sensor = this@sensorsfragment. msensorlist[position] holder.bind(sensor) override fun getitemcount(): Int { return msensorlist.size 33

34 Registering Sensor Updates public void onresume() { super.onresume(); //... // Start listening to sensor updates for (Sensor sensor : msensorlist) { msensormanager.registerlistener( this, sensor, SensorManager.SENSOR_DELAY_NORMAL); public void onpause() { super.onpause(); // Stop updates when paused msensormanager.unregisterlistener(this); Kotlin override fun onresume() { super.onresume() //... // Start listening to sensor updates for (sensor in msensorlist) { msensormanager.registerlistener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL) //... override fun onpause() { super.onpause() // Stop updates when paused msensormanager.unregisterlistener(this) 34

35 Receiving Sensor Updates public void onsensorchanged( SensorEvent sensorevent) { String sensoreventstring = sensoreventtostring(sensorevent); //... Log.d(TAG, "--- EVENT Raw Values ---\n + sensorname + "\n" + "Distance Last = > + distanceoflastvalue + "<\n" + "Distance This = >" + distanceofthisvalue + "<\n" + "Change = >" + change + "<\n" + "Percent = >" + percentagechange + "%\n" + "Last value = " + lastvaluestring + "<\n" + sensoreventstring); Kotlin override fun onsensorchanged( sensorevent: SensorEvent) { val sensoreventstring = sensoreventtostring(sensorevent) //... Log.d(TAG, "--- EVENT Raw Values ---\n" + sensorname + "\ndistance Last= >" + distanceoflastvalue + "<\n" + "Distance This= >" + distanceofthisvalue + "<\n" + "Change = >" + change + "<\n" + "Percent = >" + percentagechange + "%\n" + "Last value = " + lastvaluestring + "<\n" + sensoreventstring) See complete method for how to filter out noise. 35

36 Extracting Sensor Parameters Java public String getsensordescription( Sensor sensor) { return "Sensor: " + sensor.getname() + "; Ver :" + sensor.getversion() + "; Range: " + sensor.getmaximumrange() + "; Power: " + sensor.getpower() + "; Res: " + sensor.getresolution(); Kotlin fun getsensordescription( sensor: Sensor): String { return "Sensor: " + sensor.name + "; Ver :" + sensor.version + "; Range: " + sensor.maximumrange + "; Power: " + sensor.power + "; Res: " + sensor.resolution 36

37 References Chapter 11: Harnessing the Capabilities of your Android Device from Android SDK 3 Programming for Dummies Chapter 8 from Android Programming: The Big Nerd Ranch Guide, 3rd ed. (RecyclerView) Services: SMS: SIP (internet telephony): MediaPlayer: MediaRecorder: MediaStore class (extract metadata from media): Camera: BitmapFactory: Bitmap: Sensor: SensorEvent: 37

38 Thank You Questions and comments? 38

Android Application Model II. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Android Application Model II. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Android Application Model II CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Outline Activity Lifecycle Services Persistence Content

More information

External 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 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 information

Android Application Model I

Android 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 information

Android 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. 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 information

Mobile Programming Lecture 9. Bound Services, Location, Sensors, IntentFilter

Mobile 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 information

Terms: MediaPlayer, VideoView, MediaController,

Terms: 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 information

Xin Pan. CSCI Fall

Xin 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 information

EMBEDDED SYSTEMS PROGRAMMING Android Services

EMBEDDED 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 information

ELET4133: Embedded Systems. Topic 15 Sensors

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 information

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr.

User Interface Development. CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. User Interface Development CSE 5236: Mobile Application Development Instructor: Adam C. Champion Course Coordinator: Dr. Rajiv Ramnath 1 Outline UI Support in Android Fragments 2 UI Support in the Android

More information

Overview. Lecture: Implicit Calling via Share Implicit Receiving via Share Launch Telephone Launch Settings Homework

Overview. 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 information

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 4a: Fragments, Camera Emmanuel Agu Fragments Recall: Fragments Sub-components of an Activity (screen) An activity can contain multiple fragments, organized

More information

Android. Mobile operating system developed by Google A complete stack. Based on the Linux kernel Open source under the Apache 2 license

Android. 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 information

Services. Background operating component without a visual interface Running in the background indefinitely

Services. Background operating component without a visual interface Running in the background indefinitely Services Background operating component without a visual interface Running in the background indefinitely Differently from Activity, Service in Android runs in background, they don t have an interface

More information

Services. service: A background task used by an app.

Services. 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 information

Android CardView Tutorial

Android CardView Tutorial Android CardView Tutorial by Kapil - Wednesday, April 13, 2016 http://www.androidtutorialpoint.com/material-design/android-cardview-tutorial/ YouTube Video We have already discussed about RecyclerView

More information

Multimedia Support Classes Playing Audio Watching Video Recording Audio

Multimedia Support Classes Playing Audio Watching Video Recording Audio Multimedia Support Classes Playing Audio Watching Video Recording Audio Android provides support for encoding and decoding a variety of common media formats Allows you to play & record audio, still images

More information

Android Help. Section 8. Eric Xiao

Android 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 information

MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR

MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR MOBILE APPLICATION DEVELOPMENT LECTURE 10 SERVICES IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM Android Component A Service is an application component that runs in the background, not interacting

More information

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen

Agenda. Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Gill Cleeren Agenda Overview of Xamarin and Xamarin.Android Xamarin.Android fundamentals Creating a detail screen Lists and navigation Navigating from master to detail Optimizing the application Preparing

More information

INTRODUCTION TO ANDROID

INTRODUCTION 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 information

ListView Containers. Resources. Creating a ListView

ListView 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 information

API Guide for Gesture Recognition Engine. Version 2.0

API 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 information

CS 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 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 information

Topics Related. SensorManager & Sensor SensorEvent & SensorEventListener Filtering Sensor Values Example applications

Topics 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 information

filled by the user and display it by setting the value of view elements. Uses display.xml as layout file to display the result.

filled 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 information

Mobile Development Lecture 8: Intents and Animation

Mobile 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 information

CS 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 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 information

package import import import import import import import public class extends public void super new this class extends public super public void new

package import import import import import import import public class extends public void super new this class extends public super public void new Android 2-D Drawing Android uses a Canvas object to host its 2-D drawing methods. The program below draws a blue circle on a white canvas. It does not make use of the main.xml layout but draws directly

More information

Sensor & SensorManager SensorEvent & SensorEventListener Filtering sensor values Example applications

Sensor & 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 information

Developing Android Applications

Developing 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 information

API Guide for Gesture Recognition Engine. Version 1.1

API 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 information

ES E 3 3 L a L b 5 Android development

ES E 3 3 L a L b 5 Android development ES3 Lab 5 Android development This Lab Create a simple Android interface Use XML interface layouts Access the filesystem Play media files Info about Android development can be found at http://developer.android.com/index.html

More information

<uses-permission android:name="android.permission.internet"/>

<uses-permission android:name=android.permission.internet/> Chapter 11 Playing Video 11.1 Introduction We have discussed how to play audio in Chapter 9 using the class MediaPlayer. This class can also play video clips. In fact, the Android multimedia framework

More information

Writing 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 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 information

Fragments were added to the Android API in Honeycomb, API 11. The primary classes related to fragments are: android.app.fragment

Fragments 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 information

CS 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 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 information

Mobile Computing Fragments

Mobile 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 information

Workshop. 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 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 information

Activities and Fragments

Activities 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 information

8Messaging SMS MESSAGING.

8Messaging SMS MESSAGING. 8Messaging WHAT YOU WILL LEARN IN THIS CHAPTER How to send SMS messages programmatically from within your application How to send SMS messages using the built-in Messaging application How to receive incoming

More information

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based.

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based. 1 COS 470 - MOBILE DEVELOPMENT INTRODUCTION 2 WHAT IS ANDROID Linux-based Java/Kotlin Android Runtime (ART) System Apps SMS, Calendar, etc. Platform Architecture 3 CORE OS Linux (64 bit) Each app is a

More information

Mobile Application Development Android

Mobile 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 information

Embedded Systems Programming - PA8001

Embedded 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 information

CMSC436: Fall 2013 Week 3 Lab

CMSC436: 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 information

Exercise 1: First Android App

Exercise 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 information

Activities. 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 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 information

05. RecyclerView and Styles

05. RecyclerView and Styles 05. RecyclerView and Styles 08.03.2018 1 Agenda Intents Creating Lists with RecyclerView Creating Cards with CardView Application Bar Menu Styles and Themes 2 Intents 3 What is Intent? An Intent is an

More information

Real-Time Embedded Systems

Real-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 information

UNDERSTANDING ACTIVITIES

UNDERSTANDING 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 information

Multiple Activities. Many apps have multiple activities

Multiple 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 information

Fragments. Lecture 10

Fragments. 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 information

ORACLE UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP)

ORACLE UNIVERSITY AUTHORISED EDUCATION PARTNER (WDP) Android Syllabus Pre-requisite: C, C++, Java Programming SQL & PL SQL Chapter 1: Introduction to Android Introduction to android operating system History of android operating system Features of Android

More information

Diving into Android. By Jeroen Tietema. Jeroen Tietema,

Diving 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 information

Using Intents to Launch Activities

Using 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 information

EMBEDDED SYSTEMS PROGRAMMING Application Basics

EMBEDDED 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 information

Mobile Development Lecture 10: Fragments

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 information

The drawable/tile empty.xml file

The drawable/tile empty.xml file The X and O Symbols 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 3: Ultimate Tic-Tac-Toe Game: The Interface Dr Dimitris C. Dracopoulos Create them with the filenames x blue.png and o red.png in an

More information

Programming 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 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 information

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application.

IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application. Learning Unit Exam Project IPN-ESCOM Application Development for Mobile Devices. Extraordinary. A Web service, invoking the SOAP protocol, in an Android application. The delivery of this project is essential

More information

Fragments. Lecture 11

Fragments. 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 information

LAMPIRAN. public class MainActivity extends AppCompatActivity {

LAMPIRAN. public class MainActivity extends AppCompatActivity { LAMPIRAN 1. Coding MainActivity public class MainActivity extends AppCompatActivity { protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); this.requestwindowfeature(window.feature_no_title);

More information

Initialising the Views (GameFragment) 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 5: Ultimate Tic-Tac-Toe Game: The Interface (Part III)

Initialising 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 information

Introduction to Android Multimedia

Introduction 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 information

A Tour of Android. and some of it s APIs. Bryan Noll

A Tour of Android. and some of it s APIs. Bryan Noll A Tour of Android and some of it s APIs Bryan Noll Me professionally A good starting point http://neidetcher.blogspot.com/2009/07/android-presentation-from-denver-open.html The OS The VM Basic Views Basic

More information

UI Fragment.

UI 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 information

CS371m - Mobile Computing. More UI Navigation, Fragments, and App / Action Bars

CS371m - 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 information

Android Application Development

Android 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 information

Understanding Intents and Intent Filters

Understanding Intents and Intent Filters 255 Chapter 11 Understanding Intents and Intent Filters This chapter will delve into intents, which are messaging objects that carry communications between the major components of your application your

More information

Android Fundamentals - Part 1

Android 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 information

Programming with Android: Android for Tablets. Dipartimento di Scienze dell Informazione Università di Bologna

Programming 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 information

CS371m - Mobile Computing. More UI Action Bar, Navigation, and Fragments

CS371m - 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 information

CS378 - Mobile Computing. Anatomy of an Android App and the App Lifecycle

CS378 - 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 information

EMBEDDED SYSTEMS PROGRAMMING Application Tip: Saving State

EMBEDDED 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 information

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game

O X X X O O X O X. Tic-Tac-Toe. 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game Tic-Tac-Toe 5COSC005W MOBILE APPLICATION DEVELOPMENT Lecture 2: The Ultimate Tic-Tac-Toe Game Dr Dimitris C. Dracopoulos O X X X O O X O X The Ultimate Tic-Tac-Toe: Rules of the Game Dimitris C. Dracopoulos

More information

Android Basics. Android UI Architecture. Android UI 1

Android 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 information

Solving an Android Threading Problem

Solving 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 information

Software Practice 3 Today s lecture Today s Task

Software Practice 3 Today s lecture Today s Task 1 Software Practice 3 Today s lecture Today s Task Prof. Hwansoo Han T.A. Jeonghwan Park 43 2 MULTITHREAD IN ANDROID 3 Activity and Service before midterm after midterm 4 Java Thread Thread is an execution

More information

App Development for Smart Devices. Lec #8: Android Sensors

App 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 information

Vienos veiklos būsena. Theory

Vienos 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 information

EMBEDDED SYSTEMS PROGRAMMING UI and Android

EMBEDDED 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 information

Creating a Custom ListView

Creating 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 information

Mobile Programming Practice Background processing AsynTask Service Broadcast receiver Lab #5

Mobile 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 information

Fragment 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. Fragment Example Create the following files and test the application on emulator or device. File: AndroidManifest.xml

More information

Comp 595MC/L: Mobile Computing CSUN Computer Science Department Fall 2013 Midterm

Comp 595MC/L: Mobile Computing CSUN Computer Science Department Fall 2013 Midterm Comp 595MC/L: Mobile Computing CSUN Computer Science Department Fall 2013 Midterm Time: 50 minutes Good news: You can use ONE sheet of notes. Bad news: Closed book, no electronic computing or communications

More information

Arrays of Buttons. Inside Android

Arrays of Buttons. Inside Android Arrays of Buttons Inside Android The Complete Code Listing. Be careful about cutting and pasting.

More information

Podstawowe komponenty aplikacji, wymiana międzyprocesowa

Podstawowe komponenty aplikacji, wymiana międzyprocesowa Podstawowe komponenty aplikacji, wymiana międzyprocesowa Intencje. Budowanie intencji, komunikacja z wykorzystaniem intencji pomiędzy aktywnościami i aplikacjami. Obsługa powiadomień za pomocą klasy BroadcastReceiver.

More information

Android Media. Pro. Developing Graphics, Music, Video and Rich Media Apps for Smartphones and Tablets

Android Media. Pro. Developing Graphics, Music, Video and Rich Media Apps for Smartphones and Tablets Utilize the Android media APIs to create dynamic mobile apps Pro Android Media Developing Graphics, Music, Video and Rich Media Apps for Smartphones and Tablets Shawn Van Every Pro Android Media Developing

More information

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015

CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 CSE 660 Lab 3 Khoi Pham Thanh Ho April 19 th, 2015 Comment and Evaluation: This lab introduces us about Android SDK and how to write a program for Android platform. The calculator is pretty easy, everything

More information

1. 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 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 information

Overview of Activities

Overview 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 information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, 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 information

CS 193A. Multiple Activities and Intents

CS 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 information

Programming with Android: Activities and Intents. Dipartimento di Informatica Scienza e Ingegneria Università di Bologna

Programming 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 information

API Guide for Gesture Recognition Engine. Version 1.3

API Guide for Gesture Recognition Engine. Version 1.3 API Guide for Gesture Recognition Engine Version 1.3 Table of Contents Table of Contents...2 Gesture Recognition API...3 API URI... 3 Communication Protocol... 3 Getting Started...4 Protobuf... 4 WebSocket

More information

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB)

Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) Applied Cognitive Computing Fall 2016 Android Application + IBM Bluemix (Cloudant NoSQL DB) In this exercise, we will create a simple Android application that uses IBM Bluemix Cloudant NoSQL DB. The application

More information

Understand 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 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 information

Android Programming Lecture 7 9/23/2011

Android 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 information

Multiple devices. Use wrap_content and match_parent Use RelativeLayout/ConstraintLayout Use configuration qualifiers

Multiple 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 information

10.1 Introduction. Higher Level Processing. Word Recogniton Model. Text Output. Voice Signals. Spoken Words. Syntax, Semantics, Pragmatics

10.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 information