我正在尝试构建一个自定义拨号程序,其中包含两个用于接听和拒绝接听的按钮。 为了接听来电,我使用此post.
中的代码这在许多设备(三星,Nexus 5,华为)中运行良好,但只有华硕设备,Android监视器在我尝试回答时给出了这个例外:
Permission denied: injecting event from pid 30792 uid 10246 to window Window{3c7cf834 u0 com.asus.asusincallui/com.asus.asusincallui.InCallActivity} owned by uid 10011 <br>
FATAL EXCEPTION IN SYSTEM PROCESS: main java.lang.SecurityException: Injecting to another application requires INJECT_EVENTS permission
当屏幕关闭时,会发生 。我已经尝试将INJECT_EVENT
添加到清单但不起作用(它是系统权限)。
有什么想法吗?
我的清单:`
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.INJECT_EVENTS" />
<uses-permission android:name="android.permission.CALL_PRIVILEGED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />`
我的Build.gradle:
android { compileSdkVersion 23 buildToolsVersion "23.0.0" useLibrary 'org.apache.http.legacy'defaultConfig { applicationId "com.noatel.customdialer" minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { ... } }
}
dependencies { compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.google.android.gms:play-services-gcm:8.4.0' compile 'com.android.support:support-v4:23.4.0' compile 'hanks.xyz:htextview-library:0.1.5' compile 'com.github.castorflex.smoothprogressbar:library-circular:1.2.0'
}