如何在android屏幕中启用Show Touch指针?

时间:2016-03-25 07:04:32

标签: android

我想启用或禁用图片下方显示

enter image description here

我正在使用android studio和Maximum API level 23,我想以编程方式启用或禁用。我用这个

Settings.System.putInt(getContentResolver(),"Show Touch",1); 

code but not working but it will send a error that 
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime: java.lang.SecurityException: com.zennaxx.touchingeffect was not granted  this permission: android.permission.WRITE_SETTINGS.
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.os.Parcel.readException(Parcel.java:1599)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.content.ContentProviderProxy.call(ContentProviderNative.java:646)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.provider.Settings$NameValueCache.putStringForUser(Settings.java:1322)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.provider.Settings$System.putStringForUser(Settings.java:1671)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.provider.Settings$System.putIntForUser(Settings.java:1776)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.provider.Settings$System.putInt(Settings.java:1770)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at com.zennaxx.touchingeffect.MainActivity$1.onClick(MainActivity.java:26)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.view.View.performClick(View.java:5198)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:21147)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:739)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-25 12:13:36.059 23858-23858/com.zennaxx.touchingeffect E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-25 12:16:14.349 23858-23858/? I/Process: Sending signal. PID: 23858 SIG: 9

请任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

从API级别23,您必须Requesting Permissions at Run Time