在android刚开机时,启动 Notification ,每次都是几秒后都消失,请问下怎么让Notification一直在?
部分代码:public class AngelDaemon extends IntentService
{
public void onCreate() {
super.onCreate(); Notification notification = new Notification(R.drawable.status, getText(R.string.notification),
System.currentTimeMillis());
Log.v("Angel", "Notification ");
Intent notificationIntent = new Intent(this, AndroidDiaOperation.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Log.v("Angel", "PendingIntent ");
notification.setLatestEventInfo(this, getText(R.string.notification),
getText(R.string.notification), pendingIntent);
Log.v("Angel", "setLatestEventInfo ");
startForeground(ONGOING_NOTIFICATION, notification);
}}本来想在protected void onHandleIntent(Intent intent) 这里启动延时,但是都会被android给自动杀掉.
部分代码:public class AngelDaemon extends IntentService
{
public void onCreate() {
super.onCreate(); Notification notification = new Notification(R.drawable.status, getText(R.string.notification),
System.currentTimeMillis());
Log.v("Angel", "Notification ");
Intent notificationIntent = new Intent(this, AndroidDiaOperation.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
Log.v("Angel", "PendingIntent ");
notification.setLatestEventInfo(this, getText(R.string.notification),
getText(R.string.notification), pendingIntent);
Log.v("Angel", "setLatestEventInfo ");
startForeground(ONGOING_NOTIFICATION, notification);
}}本来想在protected void onHandleIntent(Intent intent) 这里启动延时,但是都会被android给自动杀掉.
先查API是个好习惯。API解决不了,再问。这样收获更大。