是否可以在pendingintent
中使用putExtra方法答案 0 :(得分:3)
您必须在初始化intent
对象时传递PendingIntent
。您可以在putExtra(string,string)
对象上调用intent
方法,如下所示
PendingIntent pendingIntent;
Intent intent = new Intent();
intent.setClass(mContext,activity2.class);
**intent.putExtra("string","string");** // call putExtra with intent
pendingIntent = PendingIntent.getActivity(mContext, 0, intent, 0); // here we are passing intent object. you can also call getBR or GetService , but you will always passing intent in the method.
答案 1 :(得分:1)
以下是代码:使用 Intent , putextra 和 PendingIntent < / EM> 强> ----- 意图 notificationIntent = new Intent(context,AllContacts.class); 日历c = Calendar.getInstance(); String sDate = c.get(Calendar.YEAR)+“ - ”+(c.get(Calendar.MONTH)+1)+“ - ”+ c.get(Calendar.DAY_OF_MONTH); notificationIntent。 putExtra (“searchingdob”,sDate); PendingIntent contentIntent = PendingIntent.getActivity(context,0,notificationIntent,0);
答案 2 :(得分:0)
我认为您需要在创建putExtra
的意图上使用PendingIntent
。
答案 3 :(得分:0)
是的,这是可能的。
首先使用Intent
。将Extars
值添加到其中。
将Intent调用到PendingIntent
。简单的解决方案。
希望你明白我的意思。让我知道。
答案 4 :(得分:0)
是的,你可以使用Intent和PendingIntent作为:
Intent alarmintent = new Intent(getApplicationContext(),Activity2.class);
alarmintent.putExtra("title", "Title of our Notification");
alarmintent.putExtra("note", "Description of our Notification");
PendingIntent sender = PendingIntent.getBroadcast(this, ID, alarmintent,PendingIntent.FLAG_UPDATE_CURRENT | Intent.FILL_IN_DATA);
我用它在设备中设置闹钟。希望这会对你有所帮助。