cordova-plugin-autostart
cordova-plugin-autostart copied to clipboard
autostart not working on android 10 os
I tried to develop auto start app and it's working on android 7 well but android 10 it's not working.
2020-09-27 11:27:39.437 509-2022/system_process I/PackageDexOptimizer: Running dexopt (dexoptNeeded=1) on: /data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/base.apk pkg=io.ionic.starter isa=x86_64 dexoptFlags=boot_complete,debuggable,public,enable_hidden_api_checks targetFilter=verify oatDir=/data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/oat classLoaderContext=PCL[]{PCL[/system/framework/android.test.base.jar]} 2020-09-27 11:27:39.501 412-573/? V/installd: DexInv: --- BEGIN '/data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/base.apk' --- 2020-09-27 11:27:42.298 2239-2239/? I/dex2oat32: /apex/com.android.art/bin/dex2oat32 --input-vdex-fd=-1 --output-vdex-fd=9 --updatable-bcp-packages-file=/system/etc/updatable-bcp-packages.txt --resolve-startup-const-strings=true --max-image-block-size=524288 --compiler-filter=verify --debuggable --classpath-dir=/data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA== --class-loader-context=PCL[]{PCL[/system/framework/android.test.base.jar]} --generate-mini-debug-info --compact-dex-level=none --compilation-reason=boot 2020-09-27 11:27:52.607 412-573/? V/installd: DexInv: --- END '/data/app/~~4u0wt5jDduYhqZRoBO3LSQ==/io.ionic.starter-trvTOysC86JM1N6blaqkPA==/base.apk' (success) --- 2020-09-27 11:27:57.737 509-2022/system_process I/BackgroundDexOptService: Pinning optimized code {io.ionic.starter} 2020-09-27 11:27:57.738 509-2022/system_process D/IorapForwardingService: onPackagesUpdated: io.ionic.starter 2020-09-27 11:28:24.349 509-536/system_process I/ActivityManager: Start proc 3627:io.ionic.starter/u0a152 for broadcast {io.ionic.starter/com.tonikorin.cordova.plugin.autostart.BootCompletedReceiver} 2020-09-27 11:28:24.532 3627-3627/io.ionic.starter D/ApplicationLoaders: Returning zygote-cached class loader: /system/framework/android.test.base.jar 2020-09-27 11:28:24.592 3627-3627/io.ionic.starter D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true 2020-09-27 11:28:24.607 3627-3627/io.ionic.starter D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true 2020-09-27 11:28:24.680 509-1863/system_process I/ActivityTaskManager: START u0 {flg=0x14000000 cmp=io.ionic.starter/.MainActivity (has extras)} from uid 10152 2020-09-27 11:28:24.681 509-1863/system_process W/ActivityTaskManager: Background activity start [callingPackage: io.ionic.starter; callingUid: 10152; isCallingUidForeground: false; callingUidHasAnyVisibleWindow: false; callingUidProcState: RECEIVER; isCallingUidPersistentSystemProcess: false; realCallingUid: 10152; isRealCallingUidForeground: false; realCallingUidHasAnyVisibleWindow: false; realCallingUidProcState: RECEIVER; isRealCallingUidPersistentSystemProcess: false; originatingPendingIntent: null; isBgStartWhitelisted: false; intent: Intent { flg=0x14000000 cmp=io.ionic.starter/.MainActivity (has extras) }; callerApp: ProcessRecord{1e21a9b 3627:io.ionic.starter/u0a152}] 2020-09-27 11:28:24.798 509-535/system_process W/BroadcastQueue: Background execution not allowed: receiving Intent { act=android.intent.action.USER_PRESENT flg=0x24200010 } to io.ionic.starter/com.tonikorin.cordova.plugin.autostart.UserPresentReceiver 2020-09-27 11:29:15.204 509-3455/system_process I/ActivityManager: Killing 3627:io.ionic.starter/u0a152 (adj 985): empty #17
I have the same problem. Autostrart works with android versions < 10 only
It's solved for me after below changes
<config-file parent="/manifest" target="AndroidManifest.xml" xmlns:android="http://schemas.android.com/apk/res/android"> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" /> </config-file>
Not working for me.
I am using the "cordova-plugin-autostart" plugin and the "@ ionic-native / autostart" package.
When I check the permissions it returns "true", so it can be assumed that the plugin is supposed to work.
But on android (10 and 11) nothing happens at startup or restart.
For me, only these two permissions are necessary (Android 10 + 11)
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
Relevant notes from Android documentation:
- https://developer.android.com/reference/android/Manifest.permission#SYSTEM_ALERT_WINDOW
- https://developer.android.com/guide/components/activities/background-starts
As @ShehanS noted, the user needs to manually enable "Allow display over other apps" in the app permissions to allow this plugin to work as designed.
Thanks @ShehanS and @peitschie for their detailed answers here; they solved my problem.
I've found that the SYSTEM_ALERT_WINDOW permission is not needed-- I only needed to add RECEIVE_BOOT_COMPLETED into config.xml . This is for Android 11.
Note that the app might only auto-start a minute or more after the boot looks completed and after you unlock the screen.
UP...
Already fixed in this PR but not merged yet @ToniKorin
Thanks!