我正在使用吐司消息;烤面包消息显示在棉花糖6.0以下,但对于棉花糖6.0和6. +烤面包没有显示,推送通知也没有显示。请解决这个问题。
for Toast:
Toast.makeText(context, "You can use this service once between every 8 hours", Toast.LENGTH_LONG).show();
for pushNotification:
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());
答案 0 :(得分:3)
我自己解决了我的问题,转到 声音&来自移动设置的通知。接下来,滚动到要为其调整通知设置的应用。 启用它
答案 1 :(得分:0)
试试这个,它在我的棉花糖手机中工作
android.widget.Toast.makeText(getBaseContext(), "!! Message here !!",Toast.LENGTH_LONG).show();