Mithraa
Mithraa

Reputation: 439

My Android "massage viberator" application does not stop vibrating even after the process is killed?

I will try to be as brief as possible... I have published a very simple android application it's name is "Vib-e-rator PRO". It's purpose is obvious, it can be used as a masssage vibrator or as an erotic stimulator...

My Problem is don't have an Android Phone to test my app in real time.

I have been recieving mixed comments from people. A few users say its working fine. But majority of them complained that the Phone would n quit vibrating even after the closing application.

Later i speculated that when ever the user switched off the vibrator and quit the app it would work as expected. If any user (most of em) directly closed the application ( either through the close option provided in the app itself or by pressing the END button in the phone ) without switching off the vibrator then it would not stop vibrating.

So i added myvib.Cancel() (myvib is the context for Phone Vibrator) in the exit block the close option provided in my app. For the other scenario, when it is closed by pressing the END button in phone, i have no idea how to solve it... So friends please advice me what is necessary to do... The comments i have been receiving from many users of my app is really embarassing....

Upvotes: 5

Views: 1501

Answers (2)

Rich
Rich

Reputation: 4207

Mithraa,

You might try changing the way the user exits your app. If, instead of the End button, you implement:

onCreateOptionsMenu (Menu menu),

you can create a pop-up menu that is only displayed when the user presses the menu button (So, no ugly loss of screen real estate). The menu contents are described in an xml file, and parsed by:

onOptionsItemSelected (MenuItem item).

In my application's menu, I implement Exit to shut down my various processes gracefully. It's not universally successful, but your Vibrator control shouldn't have the issues I'm facing.

One final caveat: The pop-up menu is limited to six items (I think), and IMHO starts to get ugly once you go beyond four (A fifth menu item forces a 2nd row of menu choices and I'm not aware of anything that can be done about that.)

Here's a link to a decent example:

http://developer.android.com/guide/topics/ui/menus.html

R.

Upvotes: -2

Felix
Felix

Reputation: 89576

Check out the Activity Lifecycle. I think your best solution is to call myvib.cancel() from inside onPause() or onStop(). Then call myvib.vibrate() from onResume().

Upvotes: 4

Related Questions