|
在Android 8.1系统上启动mpu会报Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification
/**
* 启动前台服务
*/
private void startForegroundService() {
Notification.Builder builder = new Notification.Builder(this);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, VideoPreviewActivity.class), 0);
builder.setContentIntent(contentIntent);
builder.setSmallIcon(com.tushikeji.facecar.R.drawable.icon);
builder.setTicker("Foreground Service Start");
builder.setContentTitle("Foreground Service");
builder.setContentText("Make this service run in the foreground.");
Notification notification = builder.getNotification();
startForeground(1234, notification);
} |
|