简体   繁体   English

Android Wear系统警报窗口权限

[英]Android Wear System Alert Window Permission

How to ask for system alert window permission on Android Wear? 如何在Android Wear上请求系统警报窗口权限? I am able to achieve the SYSTEM ALERT WINDOW for mobile but on the wearable device same code is not working for me. 我可以在移动设备上实现SYSTEM ALERT WINDOW,但是在可穿戴设备上,相同的代码对我不起作用。 If any example of SYSTEM ALERT WINDOW for wearable would help me a lot. 如果有适用于可穿戴设备的SYSTEM ALERT WINDOW的示例,会对我有很大帮助。

This is a duplicate of Requesting permissions on Android wear , but SO won't let me mark it as such because the OP didn't accept my answer there. 这是对Android WearRequesting许可的重复,但是SO不允许我将其标记为此类,因为OP在那里不接受我的回答。

The summary is that it's not possible to request this permission on Android Wear 1.x, but it is on Wear 2 (currently in beta and slated for release in early 2017). 摘要是,无法在Android Wear 1.x上请求此权限,但在Wear 2(当前为Beta版,计划于2017年初发布)上进行请求。

In addition to @String's answer, you might want to use requestPermissions() method. 除了@String的答案,您可能还想使用requestPermissions()方法。 Please note, these permissions must be requested in your manifest. 请注意,必须在您的清单中请求这些权限。

And, as mentioned in Permissions for Services , 而且,如“服务许可”中所述

only an activity can call the requestPermissions() method, so if the user interacts with your app via a service, for example a watch face, the service must open a background activity before requesting the permission. 只有活动可以调用requestPermissions()方法,因此,如果用户通过服务(例如表盘)与您的应用进行交互,则该服务必须在请求权限之前打开后台活动。

You can gain additional insights from the solutions given in this SO post and from the sample code shown in this GitHub post . 您可以从此SO帖子中提供的解决方案以及此GitHub帖子中显示的示例代码中获得更多的见解。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM