Android Programming Lecture 9 Service and broadcast receiver
Android Programming Lecture 9 Service and Broadcast Receiver
Sample App: Music Player Sweet With A Love Like You 2
Sample App: Music Player 2
Sample App (1/7) Click on the icon and get the startup Launcher activity is started by the sending of a special intent-the Launcher intent o Application Manifest declares Which Java class accepts the launcher intent
Sample App (1/7) • Click on the icon and get the startup • Launcher activity is started by the sending of a special intent – the Launcher intent o Application Manifest declares which Java class accepts the launcher intent 3
Sample App(2/7) Left side is a menu for different views The activity has a few fragments(sub activity) for navigation Google Play Music o Youtube tutoria My Library Tablet Click on updates Fragment B My Library Activity A contains ragment A and Fragment B
Sample App (2/7) • Left side is a menu for different views • The activity has a few fragments (subactivity) for navigation o Youtube tutorial • Click on My Library 4
Lien Now M Lera Sample App( 3/7) Click Albums to get into the Albums sub-activity(fragment) o Tab UI can be easily achieved T LIbrary using Tab Host View Group ATIS Amenca Town American Hi-Fi L Form Widgets Click an album name Amencan idiot 用Gdew[ Scrollview 已 HorizontalScrollview Q SearchView Adagio sostenuto Marre bokar 49 WebView 5
Sample App (3/7) • Click Albums to get into the Albums sub-activity (fragment) o Tab UI can be easily achieved using Tab Host ViewGroup • Click an album name 5
Sample App(4/7) Shows the album in a different activity Click on a track for immediate d172 playback Click adds it to the task bar o Launches a service to play Moonlight Sonat Click on the back button to return to the previous activity Allegretto o Android maintains a stack of Presto agitato activities for "back Refer to http://developer.androidcom/guide/components/tasks-and-back-stack.html 6
Sample App (4/7) • Shows the album in a different activity • Click on a track for immediate playback o Click adds it to the task bar o Launches a service to play • Click on the back button to return to the previous activity o Android maintains a stack of activities for “back” 6 Refer to: http://developer.android.com/guide/components/tasks-and-back-stack.html
● Sample App(5/7) Moon ight Sorata Playback continues, even if the user navigates away Even if the user locks the phone as long as the user does not shut down the app 7
Sample App (5/7) • Playback continues, even if the user navigates away • Even if the user locks the phone, as long as the user does not shut down the app 7
Sample App(6/7) Service can be controlled by a widget when locked Also from the notification bar By clicking the notification bar, we can get back to the musIc player 17:31-=sn Moonlight Sonata Screenshot captured USB debugging cornette Adagio sost Connected as a media device Allegretto Presto agitato Manne taian 8
Sample App (6/7) • Service can be controlled by a widget when locked • Also from the notification bar • By clicking the notification bar, we can get back to the music player 8
Sample App(7/7) Service interrupted when a call come Home 04-660HME o a Broad cast event that all the INCOMING CALL (registered)apps would receive Resumes after the call hangs up 9
Sample App (7/7) • Service interrupted when a call come o A Broadcast Event that all the (registered) apps would receive! • Resumes after the call hangs up 9
Listen Now My Library Amerca Town: Amencan H-F Adag o sostenuto Mamre han 17:31 Home tito Moonlight Sonata Adagio sostenuto Presto agitato 10
10