There is an application with activation, which starts every time the system starts and hangs in the system. I do this:

<receiver android:name="com.ad.cd" android:enabled="true" android:exported="true" android:permission="android.permission.RECEIVE_BOOT_COMPLETED" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </receiver> 

The problem is that when there is a shortage of RAM, the system slams the APU. There is a way to create a permanent notification (I did without an icon), but it infuriates users + supposedly spending extra 5MB. Are there any other ways?

Root protection (seen ups, if you slap, it gives "Application * ROOT provided" and it is back in the ranks), invisible notification (minsdk = 9, although 14 will do), other methods? I would be grateful for the advice!

  • one
    Maybe it is worth rewriting the functionality on the Service? - Lucky_spirit 2:58 pm
  • one
    Why do you breed govnokod? And still want, what someone instead of you would pick it up? For this there are services, nor how not Activiti. Do it humanly, and no one thinks of killing your task with a lack of memory. - Vladyslav Matviienko
  • metalurgus, your comment is VERY appropriate! - MoNTE48
  • @ MoNTE48 perhaps comment @metalurgus seems to you unnecessarily harsh, but it is really appropriate, it does not contain rudeness, only objective criticism, objectively if in a softer form than @metalurgus said, then your code is not optimal and solves the problem using methods would be worth it. But his comment conveys the essence much better, you really should use Service. - gadfil
  • @ MoNTE48 didn’t want to offend anyone, it’s rather a parody of an evil programmer ... - Vladyslav Matviienko

2 answers 2

I think a good way out of your situation will be a simple check (say, every minute). A check independent of the UI can be organized using the AlarmManager system service. It allows you to perform various events (start activities, send intentions) set for a specific time (and at a specific interval). In general, read - sure, it will help you.

    First, redo it to a service, and secondly, run it through startForeground () Example here: Android development. Immortal service

    So he will not be killed

    • So this is also an alert. Otherwise nothing? - MoNTE48
    • Read the note in the article below))) in red PS 1. It all works since version 2.0. 2. The startForeground method necessarily requires an alert (i.e., null transfer fails) This is done so that the user always knows that the service is working. In other words, the service that will be incognito, do not work. :) - Alexey Dorokhov