0

I've found out that pop up messages from my service provider(telecom network) is causing my app activity to get paused.Is there any way i can prevent these from pausing my activity?

shady2020
  • 115
  • 3
  • 13
  • what kind of pop up messages? any code that you can show? – Anurag Ramdasan Apr 27 '12 at 20:14
  • LastCall Charge 0.05 INR,Current balance 86.05 INR. Basically messages about call balance and message balance and what not.Been getting these on my phone very often even when no calls made.i guess could be data transfer over 2g.Anyways the thing is such pop ups could break my app/activity which has a countdown timer and a ringtone player.I was stopping the player at onPause to account for the user pressing home or back key but now the activity is getting paused even for these pop ups. – shady2020 Apr 27 '12 at 20:20
  • Short of airplane mode? Not if it's coming in via carrier additions to the platform or preloaded apps which can't be removed or opted out of by the end user. At most you can minimize the consequences of the interruption. – Chris Stratton Apr 27 '12 at 20:27

1 Answers1

1

I am not sure if there is much that you can do about blocking the pop ups from the service provider.

The easiest way to handle this situation though would be to shift your countdown timer or ringtone player to a background service.

What happens now is that when these pop ups occur your service is temporarily loses its focus and gets the focus back when the pop up is closed. Implementing your timer and stuff in the service will prevent this from happening.

EDIT:

best way is, write the entire layout as you want with all the buttons. in the onclick of activities you can call whatever the intents that you want. At the same time you can make the countdowntimer and ringtoneplayer as static objects in service.

So in the activity when you press the start button, you can just write service.countdowntimer.start() and it will start the cdt from the activity and the same for stopping the time and for the ringtone player too. You are just shifting your ringtone player and cdt to the background and implementing it in another class which extends service. rest almost everything remains same. you wont even need any sort of listener here.

Anurag Ramdasan
  • 4,189
  • 4
  • 31
  • 53
  • Well this activity also has a layout.Services cant have layouts right? – shady2020 Apr 27 '12 at 20:32
  • wouldnt matter. you can have a button in the layout of an activity which will start the countdown timer in a service. that way you can have your layout and an activity and also at the same time, implement functions in a service. i hope you got that. – Anurag Ramdasan Apr 27 '12 at 20:34
  • Well right now i am listening for some buttons inside of the cdt.On pressing of these buttons respective intents launched plus the cdt is stopped along with the ringtone and the current activity finished.I am using the cdt to specify the maximum time the ringtone is played and current activity shown.I also have the cdt and the player stop,an intent launched and this activity finished on onPause. So with service how do i go about doing all these..?Do i set some broadcast from the service for when the cdt is finished.Again what about when one of buttons is pressed?do i send broadcast to serv? – shady2020 Apr 27 '12 at 21:01