小编Mag*_*ius的帖子

getIntent()Extras总是NULL

我写了一个简单的Android应用程序,显示如下自定义通知:

Context context = getApplicationContext();          
NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification( R.drawable.icon, title, System.currentTimeMillis());  
Intent notificationIntent = new Intent( context,  this.getClass()); 
notificationIntent.putExtra("com.mysecure.lastpage", "SECURECODE"); 
PendingIntent pendingIntent = PendingIntent.getActivity( context , 0, notificationIntent, 0);               
notification.flags = notification.flags | Notification.FLAG_ONGOING_EVENT;
notification.contentView = new RemoteViews(context.getPackageName(), R.layout.notifypbar);
notification.contentIntent = pendingIntent;

notification.contentView.setTextViewText(R.id.notifypb_status_text, text);
notification.contentView.setProgressBar(R.id.notifypb_status_progress, 100, (int)(100*progress), false);

manager.notify(104, notification);
Run Code Online (Sandbox Code Playgroud)

这段代码在我的应用程序中被称为ONLY ONCE,它显示带有进度条的通知(全部正确).

现在,当用户点击此通知时,我的应用程序会处理该onResume事件.

public void onResume()
{
    super.onResume();
    // TODO: Extras è SEMPRE NULL!!! impossibile!
    Intent callingintent = getIntent(); 
    Bundle extras = …
Run Code Online (Sandbox Code Playgroud)

notifications android android-intent

74
推荐指数
4
解决办法
4万
查看次数

标签 统计

android ×1

android-intent ×1

notifications ×1