Android8.0需要显式发送广播

Android8.0新的更改,导致api26以上PendingIntent不能正常发送广播,解决办法如下:

Intent intent = new Intent(Alarms.UPDATE_NOTIFY_ACTION);
		intent.setClass(this, AlarmReceiver.class);//为其指明广播接收器,已成为发送显式广播
		PendingIntent sender = PendingIntent.getBroadcast(this, 0, intent,
				PendingIntent.FLAG_CANCEL_CURRENT);

猜你喜欢

转载自blog.csdn.net/sytandxly/article/details/81061542
今日推荐