0

I am building a radio streaming app and was wondering what would be a good design for the back and home buttons.

Should the back button stop playing the music and quit the app? Should the home button allows the music to play in the background? Any suggestions?

sealz
  • 5,348
  • 5
  • 40
  • 70
Sreekumar Menon
  • 63
  • 1
  • 1
  • 3

2 Answers2

1

The best design in my mind is not to override the default behavior of the back and home buttons.

My player puts a sticky notification into the notification area when play starts with a little persistent play arrow. When you click on the notification, it brings you to the radio controls so you can stop/pause the audio. This way, the user can leave the app using either the home or back key and you don't have to do fancy life cycle stuff to manage the state of the radio.

Nick Campion
  • 10,479
  • 3
  • 44
  • 58
  • Thanks for the comments. related question when user click on back button and come back to the app by clicking on notification ,it starts a new instance of the activity. it works fine when home button is clicked, comes back to the running instance of activity. – Sreekumar Menon Jun 18 '11 at 03:16
  • code that creates notification - notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); final int ID = 1; mNotificationManager.notify(ID, notification); – Sreekumar Menon Jun 18 '11 at 03:17
  • You'll need to modify how your activity is launched, I believe you want singleTop, but take a look at http://developer.android.com/guide/topics/manifest/activity-element.html#lmode – Nick Campion Jun 18 '11 at 13:09
  • got it fixed - http://stackoverflow.com/questions/2000102/android-override-back-button-to-act-like-home-button not sure if this is the best way.. – Sreekumar Menon Jun 18 '11 at 15:31
1

Don't override the native behavior unless there's a really good reason to. Add your own controls and leave the back button to do what it does. Keep in mind how frustrating it is when the ui suddenly does something unexpected.

Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236