I am getting null
values in service class :-
if (intent != null && intent.getAction() != null) {
matchName = intent.getStringExtra("match");
matchDate = intent.getStringExtra("time");
Log.d(" Service Match ", intent.getExtras().toString());
}
//onCreate Code
@Override
protected void onCreate(Bundle savedInstanceState) {
Button match1 = (Button) findViewById(R.id.match1);
match1.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Calendar endTime = Calendar.getInstance();
SimpleDateFormat inputFormat = new SimpleDateFormat(
"yyyy-MM-dd hh:mm:ss a");
inputFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
SimpleDateFormat nativeFormat = new SimpleDateFormat(
"yyyy-MM-dd hh:mm:ss a");
nativeFormat.setTimeZone(TimeZone.getDefault());
SimpleDateFormat nativeFormat1 = new SimpleDateFormat(
"yyyy-MM-dd hh:mm a");
String inpt = matchTimeInGMT(v); // "2014-03-22 8:45:00 PM";
Button matchButton = (Button) v;
String matchName = "ABC vs DEF";
try {
inptdate = inputFormat.parse(inpt);
date2 = nativeFormat.format(inptdate);
endTime.setTime(nativeFormat.parse(date2));
// endTime.add(Calendar.HOUR_OF_DAY, 3);
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", endTime.getTimeInMillis());
intent.putExtra("allDay", false);
intent.putExtra("rrule", "FREQ=YEARLY;COUNT=1");
intent.putExtra("endTime", endTime.getTimeInMillis());
intent.putExtra("title", matchName);
startActivity(intent);
Calendar cal = Calendar.getInstance();
cal.setTime(endTime.getTime());
Intent svc = new Intent(this,MyAlarmService.class);
svc.setAction("matchTime");
svc.putExtra("match", matchName.toString());
svc.putExtra("time", nativeFormat1.format(cal.getTime()).toString());
startService(svc);
PendingIntent alarmIntent;
Intent myIntent1 = new Intent(FIXTURE.this, MyReceiver.class);
alarmIntent = PendingIntent.getBroadcast(FIXTURE.this, 0,
myIntent1, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC, endTime.getTimeInMillis(),
alarmIntent);
} catch (Exception e) {
e.printStackTrace();
}
}
Log output -Bundle[{time=2014-03-25 12:20 AM, match=ABC Vs DEF}]
I am getting values for match
and time
but not getting assigned to matchName
and matchDate
variables. Please help.