I have to run the service using BOOT_COMPLETED Broadcast but while the Android 10 device is booting I get the following warning.
system_process W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.LOCKED_BOOT_COMPLETED flg=0x400010 } to com.rahul.http/.BootReceiver
Mainifest:
<service
android:name=".HttpUpdateService"
android:enabled="true"
android:directBootAware="true"
android:exported="true">
</service>
<receiver android:name=".BootReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
android:exported="true"
>
<intent-filter android:priority="999">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
</intent-filter>
</receiver>
I have also added permission for receiving boot_complete broadcast.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
I don't have any activity in my application.
try to add add android:directBootAware to your <receiver, as in DOCs
Try adding following attribute in your application tag in Manifest :
android:directBootAware="true"
When you received an intent on Broadcast receiver you have to add the check if your application target below the Android O version. Something like this:
if app build version greater than android O than you must called startForegroundService method with provided intent. otherwise you just called the method startService with provided intent.
Related
I tried to publish my app in production but I'm facing this issue You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without 'android:exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported
I also added android:exported="true" in service and activity, still not resolved.
If your startup Activity does not set android:exported, the same will not work.
You can try to add these into your manifest
<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
</intent-filter>
</receiver>
I scheduled alarms and i need to reschedule it after reboot the device, it is not working in android 7.1
I have registered receiver in AndroidManifest.xml and permission but no luck. It is working correctly in android 8 and above
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<receiver android:name=".services.StartBootReceiver" android:enabled="false">
<intent-filter>
<actionandroid:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
I use react-native-gcm-android and react-native-system-notification packages to manage GCM notifications (Android), everything works fine on Android 4.x but on 5.0 (ASUS_Z00AD) after reboot GCM messages not appear, log shows me
W/BroadcastQueue( 639): Reject to launch app com.Sgoomys.Main/10246 for broadcast: App Op 48
W/GCM-DMM ( 1824): broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.Sgoomys.Main (has extras) }
In AndroidManifest.xml all the settings are made according the packages documentation:
<permission
android:name="com.Sgoomys.Main.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.Sgoomys.Main.permission.C2D_MESSAGE" />
...
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.Sgoomys.Main" />
</intent-filter>
</receiver>
<service android:name="com.oney.gcm.GcmRegistrationService"/>
<service android:name="com.oney.gcm.BackgroundService"></service>
<service
android:name="io.neson.react.notification.GCMNotificationListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<receiver
android:exported="false"
android:name="com.oney.gcm.GcmBroadcastReceiver">
<intent-filter>
<action android:name="com.oney.gcm.GCMReceiveNotification" />
</intent-filter>
</receiver>
Google Play Services library is com.google.android.gms:play-services-gcm:8.4.0
Finally I solved the puzzle...
Application doesn't start at boot-up because it was blocked by Asus utility "Auto-start manager" - all recently installed apps are blocked by default.
So now I will add a check for com.asus.mobilemanager package with alert and button to start this utility and unblock autorun, but I think the correct way will be detect all possible blocking software and inform user about it.
I created a simple sample to test the BroadcastReceiver reacting to the action BOOT_COMPLETED see. below, but it is not working. After starting the tablet is no activity / app is running and in the logocat is nothing. I'm probably a mistake in the settings, but I can not find out what
I use a tablet alps 874v3 android 4.4.2 and Visual Studio 2010 with Xamarin to write Android app in .net
On SO I found some additional information:
1 Registration BroadcastReceiver have not be inside AndroidManifest.xml but must use class attributes.
2 Applications must contain BroadcastReceiverand activity otherwise the will not run on later versions of Android (for safety)
3 Once installed the application is in stopped state so i started it (system verifies that the user wants the application) and then kill and then I try to reboot.
[BroadcastReceiver(Enabled = true, Exported = true, Permission = "RECEIVE_BOOT_COMPLETED")]
[IntentFilter(new string[] { "android.intent.action.BOOT_COMPLETED"})]
public class BootBroadcastReceiver : BroadcastReceiver
{
public BootBroadcastReceiver()
{
}
public override void OnReceive(Context context, Intent intent)
{
Log.Debug("TestBoot", "BootBroadcastReceiver.OnReceive()");
context.StartActivity(typeof(UsbMainActivity));
Log.Debug("TestBoot", "BootBroadcastReceiver.OnReceive() after start activity");
}
}
[Activity(Label = "UsbMainActivity", Icon = "#drawable/icon", MainLauncher = true, Permission = "RECEIVE_BOOT_COMPLETED")]
[IntentFilter(new string[] { "android.intent.action.BOOT_COMPLETED" })]
public class UsbMainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Utils.MyLog("TestBoot", 1, "UsbMainActivity.OnCreate()");
}
}
There is a AndroidMainfest.xml which was generated by xamarin :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="TestBoot.TestBoot" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="19" />
<application android:label="TestBoot" android:icon="#drawable/icon" android:name="mono.android.app.Application" android:debuggable="true">
<activity android:icon="#drawable/icon" android:label="UsbMainActivity" android:permission="RECEIVE_BOOT_COMPLETED" android:name="md5e98891b9b152ca725e5cab653b1387f3.UsbMainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</activity>
<receiver android:enabled="true" android:exported="true" android:permission="RECEIVE_BOOT_COMPLETED" android:name="md5e98891b9b152ca725e5cab653b1387f3.BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="TestBoot.TestBoot.mono.MonoRuntimeProvider.__mono_init__" />
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.TestBoot.TestBoot" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
The problem was that after installing application i stopped via Settings- "Force Quit" and then tried to reboot. If I'm after installing stopped only a activity, so after the restart boot_completed arrived. So it seems that the application must running before the reboot and then the boot_completed arrived.
Note: Test reboot via adb console, type :
adb shell
am broadcast -a android.intent.action.BOOT_COMPLETED
add this permission to manifest
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
On some devices declaring the permission twice, once in the manifest and second as attribute to the receiver will make the receiver not working. You can leave only the permission declared inside the manifest. Check my comment (GeorgiZ) in this thread: https://forums.xamarin.com/discussion/80876/open-an-app-on-startup-after-booting-not-working.
I am developing an app which listens to incoming sms. I have added the permission:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
to my app manifest. And yes, it is not inside the receiver tag.
I am trying to test the app by sending a sms from one emulator to another. My logcat gets the following entry :
WARN/ActivityManager(66): Permission Denial: receiving Intent { act=android.provider.Telephony.SMS_RECEIVED (has extras) } to com.android.LUC requires android.permission.RECEIVE_SMS due to sender com.android.phone (uid 1001)
The weird part is that when I am testing the app on emulator running android 3.2 it works fine!
App Manifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.sms"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<application android:icon="#drawable/icon" android:label="#string/app_name" android:permission="android.permission.RECEIVE_SMS">
<activity android:name=".TestSMSReceiveActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".mysmstestcall" android:enabled="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
</manifest>
mysmstestcall is the broadcastreceiver class and TestSMSReceiveActivity is the main activity. The app fails to receive message in emulator running android 2.2. Please help!!
OK the problem is in your manifest. My working SMS broadcast receiver has the following manifest entry:
<receiver
android:name=".IncomingSmsBroadcastReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
You do not need an android:permission attribute on the receiver. You just need the following permission to receive the broadcast and be able to look at the contents of the message:
<uses-permission android:name="android.permission.RECEIVE_SMS" />
The thing most often missed is android:exported="true" when declaring the receiver which is required as you are receiving a broadcast that originates from outside your own application. Needless to say, the default for this property is 'false'. Happy SMS Receiving.