Android Programming Lecture 9 Service and Broadcast Receiver
Android Programming Lecture 9 Service and Broadcast Receiver
Sample App:Music Player With A Love Like You 2
Sample App: Music Player 2
Sample App (1/7) Click on the icon and get the startup 173 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 (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- 9☑75胡 activity)for navigation Listen Now o Youtube tutorial My Library Tablet Playlists Click on Selecting an item updates Fragment B My Library Activity A contains Fragment A and Fragment B 4
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
Lisiun Now Sample App(3/7) ● Click Albums to get into the Albums sub-activity (fragment) o Tab Ul can be easily achieved 73 介Lby using Tab Host ViewGroup A域57荐 Palette □Form Widgets Text Fields ·Click □Layouts Composite an album name ListView ExpandableList American ldiot于mercano目 ▣GridView团ScrolIView HorizontalScrollView SearchView c 2o2no ④WebView
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 941172四 Moonlight Sonata playback o Click adds it to the task bar o Launches a service to play Moonlight Sonata Click on the back button to return to the previous activity Allegretto o Android maintains a stack of activities for“back"” geomo I ⊙ 与 Refer to: http://developer.android.com/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) 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
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 4172四 41 Moonignt Sonatz Moonlight Sonata 角 Prestogta如 onmh ← 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 飞Home come Home 04-660 HOME o A Broadcast Event that all the INCOMING CALL (registered)apps would receive! Resumes after the call hangs up
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
号7的 73 个hkQ手 介面y Listen Now Playlists ©婴春 411720 1731m Moonlight Sonata NCOMING CALI Moonlight Sonata Adagio sostnuto geme 10
10