android - Service stops on clearing data from settings -
In my app I run a service in which I keep records of incoming and outgoing calls Text file (saved on internal storage) using the Broadcast Receiver but when I press the Clear Data Button (Settings => apps => MyApp = & gt; Clear Data) The service also stops when I used the Data associated with the app will no longer be released on clearing. To avoid this, you need to sign your app as a system app. Clear the data kills the app, and always happens. "Stop force" has gone through various iterations of the meaning, it was used only to kill all the processes and services, and clearing the data was also done like a force stop. There were also ancient iterations of the platform, which was not well known as the time to disable the button, perhaps that is why you make it capable in 2.2. However 3.2 I believe that "Force Stop" is changed to keep the application in a state, as long as the user has to explicitly launch it to do something special (Such as launching it from the launcher, selecting it as an input method etc.) When this change was made, "data clear" only continues to kill processes and stop its services, so the app was not in complete state, therefore the button is enabled. Edit: Example of a work code: log.d () onDestroy () method but when I
clear data Bata I is not logged in logcat. I read the same problem, but I did not find any solution. So I went through I'm really confused.
Step 1) Create an Android Broadcast receiver and for two tasks Register & lt; Service android: name = "ServiceTest" & gt; & Lt; / Services & gt; & Lt; Receiver Android: name = "ReceiverCall" & gt; & Lt; Intent-Filter & gt; & Lt; Action Android: name = "com.android.techtrainner" /> & Lt; Action Android: name = "android.intent.action.BOOT_COMPLETED" /> & Lt; / Intent-Filter & gt; & Lt; / Receiver & gt; Com.android.techtrainner Custom Action is the code included in the BroadCastReceiver class to restart the service, the public class broadcasts receivercroll broadcasts receivers {@ override public spaces (reference references, intention intentions) {Log.i (" Service stop "," ohhhhh "); Context.startService (new intent (reference, ServiceTest.class)) ;; }} Step 2) Create an Android service class, do some work there (I have taken a timer to log in) and in the diastore (public record on Destoie) {try {mTimer.cancel ()} timerTask.cancel (); } Hold (exception e) {e.printStackTrace (); } Intent = intent ("com.android.techtrainner"); Intent.putExtra ("yourvalue", "torestore"); SendBroadcast; }
Comments
Post a Comment