【发布时间】:2017-04-28 05:47:34
【问题描述】:
我尝试设置android:isolatedProcess="true",但它不起作用
其实我想一直显示永久通知
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), resourceIcon/*R.mipmap.ic_launcher*/))
.setSmallIcon(R.drawable.ic_icon_flo_not)
.setContentTitle(title)
.setOngoing(onGoing)
.setAutoCancel(autoCancelable)
.setPriority(priority)
.setContentText(message);
Uri soundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if (playSound)
mBuilder.setSound(soundUri);
if (remoteViews == null) {
// Creates an explicit intent for an Activity in your app
Intent resultIntent = new Intent(context, resultClass);
resultIntent.setAction(action);
// The stack builder object will contain an artificial back stack for the
// started Activity.
// This ensures that navigating backward from the Activity leads out of
// your application to the Home screen.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
// Adds the back stack for the Intent (but not the Intent itself)
stackBuilder.addParentStack(MainActivity.class);
// Adds the Intent that starts the Activity to the top of the stack
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);
} else {
mBuilder.setContent(remoteViews);
}
【问题讨论】:
-
您需要从您的应用程序再次启动服务。
-
@ChetanJoshi 我怎么能这样,因为省电/省电模式会杀死我的应用程序。