I followed all the guidance found on SO to autostart app at boot time.
In my manifest, I have set the right permission (RECEIVE_BOOT_COMPLETED) and also declared my broadcast receiver: .BootReceiver picking up Android.Intent.Action.BOOT_COMPLETED.
I also launch my service in BootReceiver, this is very straightforward stuff.
The thing is, my app starts at boot time on certain devices (I hope most devices) but not on some of them. I have a Xiaomi phone that gives me the following error at boot time:
"Unable to launch app com..example/10120 for broadcast Intent {act=android.intent.action.BOOT_COMPLETE flg=0x8000010 (has extras) }: process is not permitted to autostart."
I am surprised to see this message, because I can see that the list of permissions includes running at startup.
There must be a way, because Whatsapp for instance is launched at boot time.
Any clue would be highly appreciated.
Same here. I tried to delete the file in the SD card ( but the system direct to internal storage ) by using the permission WRITE_EXTERNAL_STORAGE, and get the similar message from log-cat. Maybe it can be fixed by rooting the xiao-mi mobile, that's what I searched from the Internet.
Related
For the application I write crash stability is quite important. I found that if app doesn't have autostart permission it does not receive properly onTaskRemoved callback in Service . At least this happens on my Xiaomi smartphone. When I turn this permission on manually callback started to be called.
But!! while I turned this permission on manually I found that there are applications that received this permission without help. I.e. Facebook, AliExpress, Moovit etc.
How did they received this permission? I tried to receive RECEIVE_BOOT_COMPLETED. This doesn't help. What is the trick?
To cut the story short. My logcat says:
java.lang.SecurityException: Permission Denial: starting Intent {
act=android.bluetooth.adapter.action.REQUEST_DISCOVERABLE
cmp=com.android.settings/.bluetooth.RequestPermissionActivity (has
extras) }
While I'm trying to execute:
Intent discoverIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 600);
startActivity(discoverIntent);
I have included all required permissions in the manifest. Moreover, some time ago I have written another application using bluetooth, which includes exactly this code (and I'm using the same there permissions). In that app everything works properly, here I get this exception while executing startingActivity(discoverIntent).
Do you have any ideas what's going on?
ANSWER ANSWER ANSWER
Maybe it sounds silly, but after restarting(sic!) my mobile phone, everything works perfect and I don't get any exceptions. If you have problem like this, try this simple solution.
I'm trying to start an Android Service on Boot that entails starting advertisements on boot which can be read by a BLE scanner. Do you know how to go about doing so? Currently, I keep getting "Unfortunately, 'myService' has stopped." Note: I am using Xamarin for Android development.
In order to do this you need to register a BroadcastReceiver for the system intent "android.intent.action.BOOT_COMPLETED" on your Android manifest. However, if your application is installed on the external storage use "android.intent.action.ACTION_EXTERNAL_APPLICATIONS_AVAILABLE". From this BroacastReceiver you can then start your Service.
There's a nice tutorial here that should meet your needs. Also check this other SO question which has a detailed explanation on the subject.
I have a SMS Blocking Android App. It worked fine until Google introduced SMS feature in Hangouts and so did Samsung in its ChatOn messenger. Both of them have the highest priority for SMS receiver ie 2147483647. I verified this from their manifest.
So is there anyway to decrease their SMS receiver priority using what so ever method including root?
I plan to implement a "click to fix" option after a user opens the app.
The only way I could think of doing this was to edit the manifest file of these applications.But again I am not sure how android processes the Broadcast receiver. Does it use its own internal memory to know which app will process the sms received broadcast, or does it read the manifest file of all the installed applications every time?
If there is a separate memory how can I access it(using root, if required) and if manifest file is read every time, is it possible to edit that file even with root, as I read there are signature related issues.
P.S In root programming i have just experimented with calling standard sudo commands inside an app. Also my main focus is on pre Kit Kat devices.
I need to know why my app didn't run immediately after booting in android real phone? My app run but after a few second.
First, you should make sure that your app has been installed in phone memory for your receiver to receive boot completion broadcast, As this broadcast occurs before media scanning.
just add an attribute to manifest file's root element
installlocation = "internalOnly"
rest is same as explained above.