No android.permission.RECEIVE_BOOT_COMPLETED required?

Does anyone know why my application still receives ACTION_BOOT_COMPLETED broadcasts even when my application does not have android.permission.RECEIVE_BOOT_COMPLETED permission in the manifest file? I thought it was necessary, but several textbooks that I used also did not have it. Some did. I use my phone to run CyanogenMod for testing, but I doubt it. LogCat shows my "Notified of boot" log on every boot. See the code used below.

AndroidManifest.xml

  <receiver android:name="AlarmReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <category android:name="android.intent.category.HOME" /> </intent-filter> </receiver> 

Class AlarmReceiver

  public class AlarmReceiver extends BroadcastReceiver { private static final String TAG = "MyProgram"; @Override public void onReceive(Context context, Intent intent) { try { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { Log.d(TAG, "Notified of boot"); } Intent newIntent = new Intent(context, MyService.class); context.startService(newIntent); } catch (Exception e) { Log.d(TAG, "An alarm was received but there was an error"); e.printStackTrace(); } } } 

I looked at it on an emulator and successfully reproduced the β€œproblem” on Android 2.1, 2.2 and 2.3. I get ANR (as expected) since the emulator has no queries for my applications in the database. When I remove all declared permission applications from the manifest, I get the expected failure errors when trying to use my application. However, I still get the ACTION_BOOT_COMPLETED intent broadcast at boot. Any suggestions?

+4
source share
1 answer

This may seem like a bug in Android. I can reproduce the problem on regular Nexus One and Nexus S hardware. I wrote a bug report on it.

+7
source

Source: https://habr.com/ru/post/1334765/


All Articles