service does not start after wiping memory

Asked

Viewed 57 times

0

Hello guys I am developing an application that needs a service to warn the user according to events at large times times + 24h...

then everything is working, I open the application, the service starts, close the application the service continues running, brings the notifications when necessary... My 2 problems are as follows, my cell phone as many, has the function to "clear the memory" when I run this function, my service is deleted and never runs again, only if I open the app again. realized that other apps like facebook, Whatsapp, messenger continue running normally after this process

the other is to post restart the phone the service does not run on boot Important information: I tested it in the emulator of android studio, and start as configured, it works... but in my mobile, for example not... and not of any error. I configured as follows: in the manifest:

  <receiver android:name=".StartUpBootReceiver">
        <intent-filter>
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

`public class Startupbootreceiver extends Broadcastreceiver {

@Override
public void onReceive(Context context, Intent intent) {
    NotificacaoController valor = new NotificacaoController(context);
    Toast.makeText(context,"ENTROU no STARTBOOTSERVICE",Toast.LENGTH_LONG).show();

    if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) && valor.returnNotificacao().equals("true")) {
        Toast.makeText(context,"STARTBOOTSERVICE",Toast.LENGTH_LONG).show();
        System.out.println("-------------------------------------------STARTBOOT");
        context.startService(new Intent(context, ShowNotificationService.class));
    }
}

`

  • These services that run after memory wipe, are most likely consulting the internet. And, regarding the second point, in the new devices you have to specifically enable each of them in the settings allowing the operating system to call them after booting. Make sure that’s not it.

  • in the settings would be the manifest? put as I showed the above <action android:name="android.intent.action.BOOT_COMPLETED" /> is there anywhere else? I don’t know if you can explain, thank you

  • Did you even add the permission for this broadcast? On the Internet there are people who suggest using the android.intent.action.QUICKBOOT_POWERON also, but I couldn’t find documentation for this guy.

  • About the Service, my suggestion is to check whether the onDestroy is called when you perform the cleaning. If this happens, start your Service again in the onDestroy.

  • permissao estou usando o <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> alterei o BOOT_COMPLETED" for QUICKBOOT_POWERON in this way nor in emulators does it start after the reboot of the appliance on the ondestroy, I tried calling in the following ways: startService(new Intent(this, Shownotificationservice.class); and also try calling on directCreate(); but service did not return after memory cleaning.

  • In the case of permission have to keep, but the action I would suggest adding the QUICKBOOT_POWERON next to the BOOT_COMPLETED and do not remove the other :D In the case of the Service, I would recommend the approach it suggests: http://stackoverflow.com/a/7877466/3404639.

  • Hello, I checked that the code works on android 5.0 tested in several Samsung that I have availability and works. ja my mobile phone is a LIVE BLU IV with and 4.4.3 and in it does not start at all, funny qe other app normally start, snap, facebook, Whats =/ @Wakim on the suggested post is the same problem as mine, but the answer has not solved I realized that within my service, I start a peddingIntent on a 30-minute alarm in 30 minutes, when I lower this time to 10 seconds the process becomes practically impossible to finish, it restarts, and comes back with the same time

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.