2017-07-05 75 views
0

我开始从我的服务使用startForeground stickynotification。通知会显示,但是我的设置,如标题或点击时显示的意图不生效。无法设置任何东西stickynotification

@Override 
public void onCreate() 
{ 
    Intent notificationIntent = new Intent(this, MainActivity.class); 

    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, 
                  notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); 

    Notification notification = new NotificationCompat.Builder(this) 
     //.setSmallIcon(R.mipmap.app_icon) 
     .setContentTitle("My Awesome App") 
     .setContentText("Doing some work...") 
     .setContentInfo("Server is running") 
     .setContentIntent(pendingIntent).build(); 

    startForeground(1337, notification); 
    super.onCreate(); 
} 

通知显示应用程序的名称和联系获取更多信息或停止....

当点击它带我到应用的信息,我可以forestop或卸载它。

回答

0

如果有人在这个宇宙有同样的问题,我建议不要超频你的大脑,否则你最终会失去一些小的东西,如请求权限。

设置图标解决了我的问题。