2017-10-23 12 views
-1

私はADBを使用してAndroidデバイスでロングタップをシミュレートしようとしています。Androidアプリ内で長いプレス

私は、このガイド読み:http://ktnr74.blogspot.it/2013/06/emulating-touchscreen-interaction-with.html

を、私はそれは、AndroidのUI上で動作しますが、それはアプリケーションの内部で動作しないことを知っていました。

特に、アプリケーションのテキストフィールドでロングタップをシミュレートしようとしています。

+0

LongPressListenerをtextfieldに設定しましたか? –

答えて

-1

編集:まず、これにはrootが必要です。実行時にルートを求めて:その後

public static Process requestPermission() { 
    try { 
     return Runtime.getRuntime().exec("su"); 
    } catch (IOException e) { 
     LOGGER.error("The phone needs root: ", e.getMessage()); 
     return null; 
    } 
} 

:あなたは "adbのシェルのKeyEventは" here

コマンド見つけることができます

text <string> (Default: touchscreen) 
keyevent [--longpress] <key code number or name> ... (Default: keyboard) 
tap <x> <y> (Default: touchscreen) 
swipe <x1> <y1> <x2> <y2> [duration(ms)] (Default: touchscreen) 
press (Default: trackball) 
roll <dx> <dy> (Default: trackball) 

Process process = SystemUtils.requestPermission(); 
DataOutputStream os = new DataOutputStream(process.getOutputStream()); 

cmd = "/system/bin/input swipe 100 1650 600 1650\n"; //Example 

os.writeBytes(cmd); 
os.writeBytes("exit\n"); 
os.flush(); 
os.close(); 
process.waitFor(); 

コマンドとデフォルトの源であります

+0

問題は、adbからデバイスに長いタップを送信することです。あなたの答えはそれとは関係ありません。 – TDG

+0

@TDGええ、私の悪い、私の答えを編集するつもりです。 –

+1

ええ、質問は、デバイスからデバイスに長いタップを送信することについてでした。しかし、幸運なことに、コマンドadbシェルの入力タッチスクリーンスワイプx y x y 2000を使用することで可能です。2000 2000msです。私は座標が間違っていた(彼らは絶対的ではなく相対的だった)。皆さん、ありがとうございました!!! –

関連する問題