[英]dont work “input tap x y” with external app
Try to make my app tapping on right places on some apps. 尝试让我的应用在某些应用上点击正确的位置。 I use Runtime.getRuntime().exec() with "input tap xy" adb shell command, but it working only on my activity.
我将Runtime.getRuntime()。exec()与“ input tap xy” adb shell命令一起使用,但它仅对我的活动有效。 What can i do to make it work?
我该怎么做才能使其正常工作?
Thread r;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button BtnStart = (Button) findViewById(R.id.btnStart);
try {
Runtime.getRuntime().exec("su");
} catch (IOException e) {
e.printStackTrace();
}
r = new Thread() {
@Override
public void run() {
try{
synchronized (this){
sleep(10000);
}
} catch (InterruptedException e){
}
try {
Runtime.getRuntime().exec("input tap 120 1050");
} catch (IOException e) {
e.printStackTrace();
}
}
};
View.OnClickListener StartClick = new View.OnClickListener(){
@Override
public void onClick(View v) {
StartApp("some.app.here");
r.start();
}
};
BtnStart.setOnClickListener(StartClick);
}
public void StartApp(String AppName){
Intent LaunchApp = getPackageManager().getLaunchIntentForPackage(AppName);
if (LaunchApp != null) {
startActivity(LaunchApp);
}
}
Find a way like: 找到类似的方法:
try {
dataOutputStream.writeBytes(command + "\n");
dataOutputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}
Where "command" some command with "su" preveosly 凡“命令”与“ su”的某些命令
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.