简体   繁体   English

自动启动 android 10 中的应用程序

[英]Autostart an application in android 10

I am trying to launch an application once my android is finished booting.我正在尝试在我的 android 完成启动后启动一个应用程序。 @user:3801327 has stated You could do this in several ways: @user:3801327 表示您可以通过多种方式做到这一点:

Have your app act as launcher ( set launcher declarations in manifest and set it as default launcher) Modify your default launcher (eg Launcher3) to start the app when the launcher starts.让您的应用程序充当启动器(在清单中设置启动器声明并将其设置为默认启动器)修改您的默认启动器(例如 Launcher3)以在启动器启动时启动应用程序。 Modify SystemUI app to start your app when it first starts.修改 SystemUI 应用程序以在首次启动时启动您的应用程序。 Modify SystemServer or one of the system services ( eg ActivityManagerService ) to start your app when the correct boot phase is reached (eg PHASE_BOOT_COMPLETED )修改 SystemServer 或系统服务之一(例如 ActivityManagerService )以在达到正确的启动阶段(例如 PHASE_BOOT_COMPLETED )时启动您的应用程序

I would like to modify the launcher to make this happen by decompiling it and adding the autostart command to the launcher but I am unsure how to do that.我想通过反编译启动器并将自动启动命令添加到启动器来修改启动器以实现此目的,但我不确定该怎么做。 Alternatively, I am fine doing it in init.rc but for some reason it isn't running my script (test.sh).或者,我可以在 init.rc 中执行此操作,但由于某种原因它没有运行我的脚本 (test.sh)。 If someone can explain either of these options I would be grateful.如果有人可以解释这些选项中的任何一个,我将不胜感激。

You could try running it with activity manager in the init script somewhere on early boot Im guessing?您可以尝试在早期启动时在初始化脚本中的某个位置使用活动管理器运行它我猜? Use the following command使用以下命令

am start -n com.you.package/.your.activity -a android.intent.action.VIEW

for example
am start -n com.example.app/.ui.activities.login.LoginActivity -a android.intent.action.VIEW

Im not sure if init script supports this so you could just make a bash script which runs this command and call that bash script in your init script我不确定初始化脚本是否支持这个所以你可以制作一个运行这个命令的 bash 脚本并在你的初始化脚本中调用那个 bash 脚本

Given I was working on Android 10 and it has different security then what I am used to the easiest solution for me was to modify the launcher to boot the application when it the launcher launches.鉴于我正在研究 Android 10 并且它具有不同的安全性,那么我习惯于最简单的解决方案是修改启动器以在启动器启动时启动应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM