在运行时请求android 6.0中的权限时,应用程序名称不可见
我已尝试创建一个记录\u音频运行时权限。 在AndroidManifest中,我添加了:在运行时请求android 6.0中的权限时,应用程序名称不可见,android,android-permissions,Android,Android Permissions,我已尝试创建一个记录\u音频运行时权限。 在AndroidManifest中,我添加了: // Requesting Record Permission private static final int REQUEST_RECORD=3; if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != PackageManager.PERM
// Requesting Record Permission
private static final int REQUEST_RECORD=3;
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.RECORD_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.RECORD_AUDIO)) {
Toast.makeText(getApplicationContext(), "Allow in order to use microphone for recording.", Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.RECORD_AUDIO},
REQUEST_RECORD);
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.RECORD_AUDIO},
REQUEST_RECORD);
}
}
及
在我添加的活动中:
// Requesting Record Permission
private static final int REQUEST_RECORD=3;
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.RECORD_AUDIO)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.RECORD_AUDIO)) {
Toast.makeText(getApplicationContext(), "Allow in order to use microphone for recording.", Toast.LENGTH_LONG).show();
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.RECORD_AUDIO},
REQUEST_RECORD);
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.RECORD_AUDIO},
REQUEST_RECORD);
}
}
有人能指出哪里出了问题吗?权限工作正常,但对话框中没有显示应用程序的名称。为什么会这样
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="My.Spinner.Style" parent="Base.Widget.AppCompat.Spinner.Underlined">
</style>
<style name="AppTheme.navtheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#2196F3</item>
<item name="colorPrimaryDark">#2196F3</item>
<item name="colorAccent">#03A9F4</item>
</style>
<style name="AppTheme.popupTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>
@颜色/原色
@颜色/原色暗
@颜色/颜色重音
#2196F3
#2196F3
#03A9F4
真的
假的
colors.xml
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="foreground_material_light">#FFFFFF</color>
<color name="abc_primary_text_material_light">#FFFFFF</color>
<color name="abc_secondary_text_material_light">#FFFFFF</color>
#3F51B5
#303F9F
#FF4081
#FFFFFF
#FFFFFF
#FFFFFF
您是否在代码中添加了这一行:
dialog.setTitle("Record Audio"); //Your Title
问题要么在您的主题中,要么在您的应用程序名称中 应用程序名称为空,或者您使用了错误的主题,因为该名称不可见
您可以看到应用程序名在那里,但它可能受到主题或Textcolor的限制,在
主题中问题在于我的手机主题。当我把它改为系统默认值时,一切都正常了。但不知何故,对于其他一些应用程序,权限工作正常。Post your styles.xml Post your manifest,你的应用程序名是什么?你在哪里定义的?我已经添加了styles.xml和colors.xml。我的应用程序名在清单下定义为
,在OP的问题中对话框在哪里?权限对话框无法自定义。