0
在我的android应用程序中,我希望让用户有权使用google playservices。有没有办法做到这一点?请求你访问GooglePlayServices
喜欢阅读的接触中,我们使用:
// Here, thisActivity is the current activity
if (ContextCompat.checkSelfPermission(getActivity(),
android.Manifest.permission.)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),
android.Manifest.permission.READ_CONTACTS)) {
// Show an expanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(getActivity(),
new String[]{android.Manifest.permission.READ_CONTACTS},
MY_PERMISSIONS_REQUEST_READ_CONTACTS);
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
P.S:我gradle.build文件有:
compile 'com.google.android.gms:play-services:9.0.2'
compile 'com.google.android.gms:play-services-location:8.1.0'
“我想问问用户许可使用谷歌的playservices” - 欢迎您来显示一个对话框,询问用户是否应该使用Play服务。如果用户说不,请不要在您的应用中使用Play Services API。但是,除非他们在我不看的时候添加了这个功能,否则Play Services没有内置此功能。您必须显示自己的对话框并自行跟踪用户的选择。 – CommonsWare
据我所知,您无需申请使用Google Play服务的权限。 –