完成活动后Android android.permission.INTERACT_ACROSS_USERS警告

时间:2018-06-19 01:45:03

标签: android android-permissions

我的应用程序服务在LockScreen中启动活动(Manifests.xml中的android:showOnLockScreen =“true”选项)。

LockScreen活动设置onTouch侦听器。

在onTouch中,它会调用完成()来关闭活动

完成()功能会产生警告消息'需要android.permission.INTERACT_ACROSS_USERS'

如何解决?

以下是Manifests.xml

<service android:name=".LockScreenService" />
<activity android:name=".LockScreenActivity"
    android:showOnLockScreen="true"
    android:launchMode="singleInstance"
    android:theme="@style/AppThemeNoAction">
</activity>

以下是onTouch Source上的锁屏活动

@Override
public boolean onTouch(View v, MotionEvent event) {
    finish()
}

以下是警告日志

W/System.err: java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=20053, uid=10216 requires android.permission.INTERACT_ACROSS_USERS
W/System.err:     at android.os.Parcel.readException(Parcel.java:1958)
W/System.err:     at android.os.Parcel.readException(Parcel.java:1904)
W/System.err:     at android.sec.clipboard.IClipboardService$Stub$Proxy.isEnabled(IClipboardService.java:757)
W/System.err:     at com.example.android.content.clipboard.SemClipboardManager.isEnabled(SemClipboardManager.java:1008)
W/System.err:     at android.widget.TextView.getSecClipboardEnabled(TextView.java:16133)
W/System.err:     at android.widget.TextView.onDetachedFromWindowInternal(TextView.java:7178)
W/System.err:     at android.view.View.dispatchDetachedFromWindow(View.java:18645)
W/System.err:     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3878)
I/chatty: uid=10216(u0_a216) com.example.lockscreen identical 4 lines
W/System.err:     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3878)
W/System.err:     at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:4001)
W/System.err:     at android.view.ViewRootImpl.doDie(ViewRootImpl.java:7267)
W/System.err:     at android.view.ViewRootImpl.die(ViewRootImpl.java:7244)
W/System.err:     at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:483)
W/System.err:     at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:421)
W/System.err:     at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:131)
W/System.err:     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4643)
W/System.err:     at android.app.ActivityThread.-wrap5(Unknown Source:0)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1757)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:105)
W/System.err:     at android.os.Looper.loop(Looper.java:164)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6938)

06-19 10:30:50.615 20053-20053/com.example.lockscreen W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
W/System.err: java.lang.SecurityException: Permission Denial: getCurrentUser() from pid=20053, uid=10216 requires android.permission.INTERACT_ACROSS_USERS
W/System.err:     at android.os.Parcel.readException(Parcel.java:1958)
W/System.err:     at android.os.Parcel.readException(Parcel.java:1904)
W/System.err:     at android.sec.clipboard.IClipboardService$Stub$Proxy.isEnabled(IClipboardService.java:757)
W/System.err:     at com.example.android.content.clipboard.SemClipboardManager.isEnabled(SemClipboardManager.java:1008)
W/System.err:     at android.widget.TextView.getSecClipboardEnabled(TextView.java:16133)
W/System.err:     at android.widget.TextView.onDetachedFromWindowInternal(TextView.java:7178)
W/System.err:     at android.view.View.dispatchDetachedFromWindow(View.java:18645)
W/System.err:     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3878)
I/chatty: uid=10216(u0_a216) com.example.lockscreen identical 4 lines
W/System.err:     at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3878)
W/System.err:     at android.view.ViewRootImpl.dispatchDetachedFromWindow(ViewRootImpl.java:4001)
W/System.err:     at android.view.ViewRootImpl.doDie(ViewRootImpl.java:7267)
W/System.err:     at android.view.ViewRootImpl.die(ViewRootImpl.java:7244)
W/System.err:     at android.view.WindowManagerGlobal.removeViewLocked(WindowManagerGlobal.java:483)
W/System.err:     at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:421)
W/System.err:     at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:131)
W/System.err:     at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4643)
W/System.err:     at android.app.ActivityThread.-wrap5(Unknown Source:0)
W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1757)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:105)
W/System.err:     at android.os.Looper.loop(Looper.java:164)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6938)

06-19 10:30:50.617 20053-20053/com.example.lockscreen W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
D/ViewRootImpl@bee7239[LockScreenActivity]: dispatchDetachedFromWindow
D/InputEventReceiver: channel '7c33270 com.example.lockscreen/com.example.lockscreen.LockScreenActivity (client)' ~ Disposing input event receiver.
D/InputEventReceiver: channel '7c33270 com.example.lockscreen/com.example.lockscreen.LockScreenActivity (client)' ~NativeInputEventReceiver.

1 个答案:

答案 0 :(得分:0)

高于目标API 23版本,应用程序通过弹出窗口获得权限。你有弹出窗口的权限吗?

修改  您可以使用checkSelfPermission()requestPermissions()来检查权限或获得权限。