如何在Android M中启用Android权限而无需用户担心
我正在用L代码库构建apk,这个应用程序使用android.permission.READ\u PHONE\u STATE,在M设备上也可以正常工作 但当我使用相同的权限构建相同的应用程序时,android M会提示用户关注,是否有任何方法可以在没有用户关注的情况下启用这些权限如何在Android M中启用Android权限而无需用户担心,android,android-6.0-marshmallow,Android,Android 6.0 Marshmallow,我正在用L代码库构建apk,这个应用程序使用android.permission.READ\u PHONE\u STATE,在M设备上也可以正常工作 但当我使用相同的权限构建相同的应用程序时,android M会提示用户关注,是否有任何方法可以在没有用户关注的情况下启用这些权限 我的应用程序是系统应用程序。如果你想使用Android API 23的任何新功能,这是不可能的 从Android 6.0(API级别23)开始,用户在应用程序运行时授予应用程序权限,而不是在安装应用程序时。这种方法简化了
我的应用程序是系统应用程序。如果你想使用Android API 23的任何新功能,这是不可能的 从Android 6.0(API级别23)开始,用户在应用程序运行时授予应用程序权限,而不是在安装应用程序时。这种方法简化了应用程序安装过程,因为用户在安装或更新应用程序时不需要授予权限。它还为用户提供了对应用程序功能的更多控制;例如,用户可以选择让摄像头应用程序访问摄像头,但不访问设备位置。用户可以随时通过进入应用程序的设置屏幕撤销权限 在另一种情况下,你可以将Android API降级到22,但不建议这样做 您应该更改
build.gradle
,如下所示:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "your.app.id"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "you.app.id"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.0'
}
对这样的事情:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "your.app.id"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "you.app.id"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.0'
}
记住只编译依赖项中的android library版本22或更低版本,如com.android.support:design:22.2.0'您好,非常感谢您的回复。是的,我想使用指纹api。所以,似乎我必须像谷歌应用程序一样处理这些权限。像launcher一样。谢谢你的支持