Method of restarting app after silent installation of Android program

1: Demand profile

The boss put forward a requirement before. The app running on the advertising machine needs to complete the automatic upgrade function. The advertising machine is non touch screen and cannot be clicked manually. Therefore, the app must be downloaded automatically, installed and upgraded automatically. After the installation is completed, the app will continue to operate. It is best not to use other apps to realize the above functions.

2: Realization idea

The first way to realize this function is to install silently. Since the advertising machine is already root, the silent installation is relatively smooth. The main code for installing the app is as follows:

The above methods can be installed smoothly, but can not realize that the software can continue to run after the software installation is completed, because after the installation, the current app process has been killed. The boss's requirement for the normal operation of the software after installation cannot be realized. At this time, if we still want to realize this requirement with Android, it cannot be realized. Because the app process is killed, we need to start our app with the help of a third party. The first thing I thought of was that Linux executes the am start command, but this command cannot be executed immediately, Therefore, sleep is required to realize this requirement. The command format is as follows: sleep time (in seconds), am start - N, and the complete code is as follows:

Permissions involved:

Note: not all root devices can execute process localprocess = runtime.exec ("Su"); This requires hardware support. I've encountered this pit. Through the above two methods, the silent installation can be realized. After the installation, the app automatically needs to meet the requirements.

summary

The above is the method of restarting the app after silent installation of Android programs introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>