Comments (10)
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>
from cordova-plugin-autostart.
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.
from cordova-plugin-autostart.
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.
from cordova-plugin-autostart.
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
from cordova-plugin-autostart.
I have the same problem.
Autostrart works with android versions < 10 only
from cordova-plugin-autostart.
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.
from cordova-plugin-autostart.
UP...
from cordova-plugin-autostart.
Already fixed in this PR but not merged yet @ToniKorin
from cordova-plugin-autostart.
Thanks!
from cordova-plugin-autostart.
from cordova-plugin-autostart.
Related Issues (20)
- can't use window.plugins.autoStart.enable() HOT 1
- Not working on Android 5.0.1 HOT 2
- IOS - Plugin 'AutoStart' not found HOT 1
- Detect When Started by User and When by Plugin HOT 1
- Expose actions to enable/disable PackageReplacedReceiver HOT 3
- Not switching autostart to on in the app HOT 1
- how to enable a Service?
- This does not work for Ionic 3 HOT 6
- Not working on Android 8.1
- Is this code here ?
- it can be in the background
- Can I use the plugin to start my app in background (or as a service) ? HOT 1
- I want my application to always be running, never to die, and to ignore the physical buttons HOT 1
- Java.lang.RuntimeException HOT 1
- Plugins no funciona Ionic 4 HOT 6
- Error HOT 1
- Plugin not working on Ionic 4 HOT 1
- for the background service
- Using with Stencil + Cordova HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-autostart.