创建新挂起的意图每一个在Android的时间 [英] Create new Pending Intent every time in Android

查看:122
本文介绍了创建新挂起的意图每一个在Android的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建evertime挂起的意图。目前我的现有挂起的意图是越来越更换新的。我TRID使用FLAG_ONE_SHOT以及CANCEL_CURRENT,但没有奏效。

How do i create pending intent evertime. currently my existing pending intent is getting replaced with new one. I trid using FLAG_ONE_SHOT as well as CANCEL_CURRENT but it didn't work.

有人可以帮帮我吗?

谢谢 chintan

thanks chintan

推荐答案

添加一个随机数请求code这样的:

add a random number to the request code like that:

Intent intent = new Intent(context, YourClassname.class);
intent.putExtra("some data", "txt");  // for extra data if needed..

Random generator = new Random();

PendingIntent i=PendingIntent.getActivity(context, generator.nextInt(), intent,PendingIntent.FLAG_UPDATE_CURRENT);

这篇关于创建新挂起的意图每一个在Android的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆