gpt4 book ai didi

android - PendingIntent 错误(必须是 : PendingIntent. FLAG_ONE_SHOT 中的一个或多个......)

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:57:48 31 4
gpt4 key购买 nike

我正在尝试在 Android 中创建一个 PendingIntent。这是代码

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…..)

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

最佳答案

当方法调用需要 PendingIntent 标志时,您正在传递 Intent.FLAG_ACTIVITY_NEW_TASK。如果你想将 Intent.FLAG_ACTIVITY_NEW_TASK 添加到你的 Intent,你需要这样做:

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

关于android - PendingIntent 错误(必须是 : PendingIntent. FLAG_ONE_SHOT 中的一个或多个......),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32304771/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com