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);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
firstTime, 24*60*60*1000 , sender);

..
..

//My Receiver Class Code

public class AlarmReceiver extends BroadcastReceiver{

@Override
public void onReceive(Context context, Intent intent) {

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

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Yahoo [Bot] and 14 guests