Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android PendingEvent错误(必须是一个或多个:PendingEvent.FLAG_one_SHOT…;)_Android_Android Intent_Notifications - Fatal编程技术网

Android PendingEvent错误(必须是一个或多个:PendingEvent.FLAG_one_SHOT…;)

Android PendingEvent错误(必须是一个或多个:PendingEvent.FLAG_one_SHOT…;),android,android-intent,notifications,Android,Android Intent,Notifications,我正在尝试在Android中创建一个PendingEvent。这是密码 mNotificationIntent = new Intent(getApplicationContent(), MyAlarm.class); mContentIntent = PendingIntent.getActivity(getApplicationContext(), 0, mNotificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK

我正在尝试在Android中创建一个PendingEvent。这是密码

mNotificationIntent = new Intent(getApplicationContent(), MyAlarm.class);
mContentIntent = PendingIntent.getActivity(getApplicationContext(),
                   0, mNotificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK);
我得到了以下错误:

  Must be one or more of: PendingIntent.FLAG_ONE_shot,PendingIntent.FLAG_NO_CREATE, 
         PendingIntent.FLAG_UPDATE_CURRENT, 
         Intent.FILL_IN_ACTION, Intent.FILL_IN_DATA, Intent.FILL_IN_CATEGORIES…..)

为什么会显示此错误?如何解决这个问题?请帮忙。谢谢。

当方法调用需要一个
pendingent
标志时,您正在传递
Intent.FLAG\u ACTIVITY\u NEW\u TASK
。如果要将
Intent.FLAG\u ACTIVITY\u NEW\u TASK
添加到
Intent
中,则需要如下操作:

mNotificationIntent = new Intent(getApplicationContent(), MyAlarm.class);
mNotificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContentIntent = PendingIntent.getActivity(getApplicationContext(),
               0, mNotificationIntent, 0);

为什么?你读过
pendingent#getActivity(上下文上下文、int请求代码、意图意图、int标志)
javadocs吗?@pskink pendingent#getActivity javadoc不清楚:涉及到两个意图,每个意图都有自己的标志(?),javadoc对哪个意图有意图有点模糊。FLAG#ACTIVITY#NEW任务集。