美文网首页
Android 模拟点击

Android 模拟点击

作者: Exception_Cui | 来源:发表于2017-12-01 10:09 被阅读21次

客户有个需求是通过某个按键 默认打开camera 的前置摄像头并且录像
默认打开前置摄像头这个简单,但是要录像就有点难了,而且要保证camera的UI问题,
最后决定还是模拟点击事件

                public void run() {
                    try {
                        Log.d(LOG_TAG, "isCreate() isCreate="+isCreate);
                        if(isCreate){
                            this.sleep(500);
                        }
                        Process p = Runtime.getRuntime().exec("input touchscreen  tap 96 290");  96=x 290=y
                        int status = p.waitFor();
                        if (status == 0) {
                            Log.d(LOG_TAG, "input ok");
                        }else{
                            Log.d(LOG_TAG, "input file");
                        }
                    } catch (IOException e) {
                        Log.e(LOG_TAG, "input test Failed: IOException");
                    } catch (InterruptedException e) {
                        Log.e(LOG_TAG, "input test Failed: InterruptedException");
                    }
                };
            }.start();  
、、、 

相关文章

网友评论

      本文标题:Android 模拟点击

      本文链接:https://www.haomeiwen.com/subject/clrwhxtx.html