getStringExtra from Intent Returns Null

Put your problem here if it does not fit any of the other categories.

getStringExtra from Intent Returns Null

Postby gmsk19 » Thu Dec 17, 2009 8:39 am

Hi All,
I am using AlarmManager to schedule Events on a Particular time . I Use Intents for this purpose and i set some Extra Information using putExtra method.
The Event is Triggered at the Time Selected. However when i Use getStringExtra in the onReceive Method of my BroadcastReceiver subclass the value returned is null; Can anyone tell what i am missing??

Here is my code:
//From Actvity

Intent intent = new Intent(this, AlarmReceiver.class);
PendingIntent sender = PendingIntent.getBroadcast(this,
REQUEST_CODE, intent, 0);
intent.putExtra("USERNAME", "jimi");
String temp = intent.getStringExtra("USERNAME"); //returns "jimi" works here
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
firstTime, 24*60*60*1000 , sender);


//My Receiver Class Code

public class AlarmReceiver extends BroadcastReceiver{

public void onReceive(Context context, Intent intent) {

String name = intent.getStringExtra("USERNAME"); //returns null :(
Warm Regards,
Shashi Kiran G M
Once Poster
Once Poster
Posts: 1
Joined: Thu Dec 17, 2009 8:32 am
Location: Bangalore


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 6 guests