android - 为什么 toast 消息在 Marshmallow 6.0.1 中不显示,而低于 6.0 则显示

标签 android

我正在使用 toast 消息传递; Toast 消息的显示远低于 Marshmallow 6.0,但对于 Marshmallow 6.0 和 6.+ Toast 未显示,推送通知也未显示。请解决这个问题。

toast :

Toast.makeText(context, "You can use this service once between every 8 hours", Toast.LENGTH_LONG).show();

对于推送通知:

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
mBuilder.setSmallIcon(R.drawable.ic_warning_24dp).setContentTitle("Friends in danger").setContentText("Save friends in danger.");
//Intent resultIntent=new Intent(context,DangerFriendsMapsActivity.class);
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(context);
taskStackBuilder.addParentStack(DangerFriendsMapsActivity.class);
taskStackBuilder.addNextIntent(toDangerIntent);
PendingIntent pendingIntent = taskStackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(pendingIntent);
Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
mBuilder.setSound(alarmSound);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, mBuilder.build());

最佳答案

我自己解决了我的问题,请转到 来自移动设置的声音和通知。接下来,滚动到您要调整通知设置的应用程序。 启用它

关于android - 为什么 toast 消息在 Marshmallow 6.0.1 中不显示,而低于 6.0 则显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40067977/

相关文章:

Android 从 CustomView 中绘制 TextView

Android 应用程序 - 在 apk 中 bundle 视频是个坏主意吗?

java - React Native Android 桥错误 : Must be called on main thread

android - 如何在 Osmand Android 中更改 primaryRoadColor?

android - 如何在线性布局中添加 ScrollView

android - 如何在 SeekBar 拇指中间添加 TextView?

android - Dexguard 发布 apk 不显示 UI automator 中元素的资源 ID

android - Google+ Android PlusClient 连接/断开

Android TTS 语音合成器

Android Studio 2.1.2 渲染问题。 VectorDrawable_Delegate.nDraw