[英]How to Programmatically press a button on Install/UnInstall APK Screen in android
Basically I want to install/uninstall an app on my android device from a remote Server. 基本上,我想从远程服务器在Android设备上安装/卸载应用程序。
I send a specific message (such as install or uninstall) from the remote server to my device. 我从远程服务器向设备发送特定消息(例如安装或卸载)。
But when the device initiates the process a system genrated Intent will start and shows the message below. 但是,当设备启动该过程时,系统生成的Intent将启动并显示以下消息。
The OK button must be pressed in order to continue the process. 必须按下“确定”按钮才能继续该过程。
How can I programmatically press this button from the remote server and continue the process? 如何以编程方式从远程服务器上按下此按钮并继续该过程?
Hopefully you understand what I want to explain. 希望您理解我要解释的内容。
Any suggestions or ideas? 有什么建议或想法吗?
I'm afraid that this is possible only from play store . 恐怕只有在play store才能做到。 Click on the recycle bin, but not for external apps. 单击回收站,但不单击外部应用程序。
You can only ask the system to uninstall an app. 您只能要求系统卸载应用程序。 Here's the reference . 这是参考 。
Also, as pointed out in the comments: 另外,正如评论中指出的那样:
I am looking the same solution for uninstalling any application by sending a SMS from server. 我正在寻找通过从服务器发送SMS来卸载任何应用程序的相同解决方案。 Bellow I'm giving some sample code it may help you.But you need your device as rooted one. 贝娄(Bowow)我正在提供一些示例代码,它可能会对您有所帮助。但是您需要将设备作为根目录。 For rooting your device please download s/w from bellow link http://forum.xda-developers.com/showthread.php?t=803682 要生根设备,请从以下链接下载软件: http://forum.xda-developers.com/showthread.php? t= 803682
The code is 该代码是
public class MainActivity extends Activity {
Context context;
// boolean isEnabled;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Uninstall();
}
private void Uninstall() {
Process process;
try {
process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("mount -o remount,rw -t rfs /dev/stl5 /system; \n");
os.writeBytes("rm -r /system/app/ActionsContentViewExample.apk; \n");
os.writeBytes("mount -o remount,ro -t rfs /dev/stl5 /system; \n");
} catch (IOException e) {
e.printStackTrace();
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.