1

I want helping app for proper working of my main application.My idea is to get Broadcast for android.intent.action.PACKAGE_RESTARTED and android.intent.action.PACKAGE_DATA_CLEARED but problem is Document states that the Restarted/Cleared package does not receive this broadcast .So I want to make a helping app that will be called when my main app is restarted or cleaned.And from there I can tell my main app that package is restared/cleaned so perform according to that .

So Finally my question is how can I do that, should I ask user to install that app for better performance or is there any way to intall it without asking user.Or anybody having better idea to tackle my problem without using helping app.

Shakeeb Ayaz
  • 6,200
  • 6
  • 45
  • 64

2 Answers2

0

Store a param into SharedPreferences. If the app was cleared, the param disapears and controling this you could decide if show (or not) the intro help

iflorit
  • 740
  • 5
  • 10
0

First it's important to understand that what you are asking to do is security volition and could be used to harm the user.

Lets hope that my next advises will not be used under such context:

  1. Helping app is indeed a good option. You cannot avoid asking the user to install it, and more important, review it's permissions. How ever you do not have to create a lunch activity there, so the user will not be able to run it. The helper application can create a service to listen for those broadcasts. Also it will be a good idea to make the service foreground.
  2. You can create an alarm that will wake up your service every second. If your activity been killed, you would notice this. You can use SharedPreferences, to save your application state: AppStarted, AppFinished. Also it will protect you from Force-Stop.
  3. Also I think if you only make a service that is running in background(foreground), other applications would not be able to kill you, only when the user will press on the force-stop button, from the applications settings.
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
  • Right it is security volition.But actually the problem is that after I use the built in Task Manager to Clean Memory/Ram, My widget stops working.And android.intent.action.PACKAGE_DATA_CLEARED broadcast cannot be received by same package ,which is cleaned .AFAIK this is the only way to acknowledge that task manager cleaned my data.But my helping app can acknowledge it as it is different package .And from there I can reinitialize my widget onUpdate(problem solved).here is my orignal question http://stackoverflow.com/questions/20630888/widget-does-not-works-after-clear-memory plz have a look – Shakeeb Ayaz Dec 19 '13 at 12:50