我请求Marshmallow的权限有问题,我有这个功能
private void requestPermission() {
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) {
Toast.makeText(this, "GPS permission allows us to access location data. Please allow in App Settings for additional functionality.", Toast.LENGTH_LONG).show();
} else {
ActivityCompat.requestPermissions(this, new String[]
{Manifest.permission.ACCESS_FINE_LOCATION}, MY_LOCATION_REQUEST_CODE);
}
}
还有我的进口货
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
我对build.gradle有依赖性
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.jakewharton:butterknife:8.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:25.1.0'
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
testCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile 'com.android.support:support-annotations:25.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.19.0'
compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'
compile 'com.parse:parse-android:1.13.1'
我得到
"无法解析"ActivityCompat.shouldShowRequestPermissionRationale"和"ActivityCompat.requestPermissions"中的方法"
关于可能发生的事情的任何想法?
我建立了一个解决方案,改变了进口
compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1'
自
compile('fr.avianey.com.viewpagerindicator:library:2.4.1') {
exclude group: 'com.google.android', module: 'support-v4'
}
它解决了一切
这可能会有所帮助。它显示了如何检查是否已授予权限,并请求新的权限(在本例中是录制音频和写入外部存储)
if (ContextCompat.checkSelfPermission(MainActivity.this,
Manifest.permission.WRITE_EXTERNAL_STORAGE) + ContextCompat
.checkSelfPermission(MainActivity.this,
Manifest.permission.RECORD_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale
(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) ||
ActivityCompat.shouldShowRequestPermissionRationale
(MainActivity.this, Manifest.permission.RECORD_AUDIO)) {
mToggleButton.setChecked(false);
Snackbar.make(findViewById(android.R.id.content), R.string.label_permissions,
Snackbar.LENGTH_INDEFINITE).setAction("ENABLE",
new View.OnClickListener() {
@Override
public void onClick(View v) {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission
.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO},
REQUEST_PERMISSIONS);
}
}).show();
} else {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission
.WRITE_EXTERNAL_STORAGE, Manifest.permission.RECORD_AUDIO},
REQUEST_PERMISSIONS);
}
} else {
(function here)
}
marshmallow-jsonapi Homepage: http://marshmallow-jsonapi.readthedocs.io/ JSON API 1.0 (https://jsonapi.org) formatting with marshmallow. marshmallow-jsonapi provides a simple way to produce JSON API-c
Flask-Marshmallow Flask + marshmallow for beautiful APIs Flask-Marshmallow is a thin integration layer for Flask (a Python web framework) and marshmallow (an object serialization/deserialization libra
我在数据库中有Consumer表,其中Consumer_type列上有check约束,如下所示: 现在,从hibernate方面,我想添加check约束注释,该注释只允许消费者类型表中的“ACCOUNT”和“ORGANIZATION”值。 为此,我应该使用哪个hibernate/jpa注释?
有人能解释一下<code>是可选的</code>如何帮助我们避免<code>NullPointerException</code>吗? 这段代码不是也容易出现<code>NullPointerException</code>吗?如果是这样的话,那么为什么这个代码比其他代码更受欢迎 除了帮助我们了解函数是否实际具有返回值之外,还提供了什么可能的好处
我想请求android的许可。准许READ\u EXTERNAL\u存储,用于获取媒体数据。 但在请求该权限之前,我想通过选中“永不再次询问”复选框来了解该权限是否被用户阻止。 有没有正确的方法知道“永远不要再问”的许可? 所以如果我能理解“再也不显示”是否被点击。