1
我有一個創建一個Notification
,其中日期已過,爲String
,通過putExtra
,這樣一個Service
:PutExtras改變我的日期?
Calendar cal=Calendar.getInstance();
cal.set(2013, 3, 27);
Date d=new Date(cal.getTimeInMillis());
SimpleDateFormat format=new SimpleDateFormat("dd/MM/yyyy");
String fechafinal=format.format(d);
Intent notIntent=new Intent(c, AlertsActivity.class);
notIntent.putExtra("fechafin",fechafinal);//Along with other values, I pass this one
PendingIntent contIntent = PendingIntent.getActivity(
c, 0, notIntent, 0);
Builder notif = new NotificationCompat.Builder(c);
隨着Log.i
,我可以看到那裏,fechafinal
值設置正確的,正確的價值,它是,27-04-2013。如果我是正確的,當用戶點擊Notification
時調用的Activity
是AlertsActivity
。
在AlertsActivity class
(該事項件):
SimpleDateFormat formatofecha = new SimpleDateFormat("dd/MM/yyyy");
String fecha;
bundle=getIntent().getExtras();
fecha=formatofecha.format(Calendar.getInstance().getTime());
String fechaFin;
fechaFin=bundle.getString("fechafin");
Notificacion noti=new Notificacion(bundle.getString("nombre"), bundle.getString("lugar"),
fecha,
fechaFin,
bundle.getString("dinero"),
bundle.getBoolean("buzoneo"),
bundle.getString("desc"),
bundle.getString("labor"),
bundle.getString("horainicio"),
bundle.getString("horafin"));
PD:「Notificacion」是我存儲將在某種工作機會的詳細圖中呈現的值的類,它不通知的Android類。
如果我在這裏放一個Log.i
......我看到fechafin
裏面有「2013/12/12」,我不知道爲什麼。這讓我瘋狂!
任何人都有同樣的問題?謝謝!
你可以顯示你的接收器類嗎? – Kanth 2013-04-08 10:53:55
你是什麼意思接收機類?通知的接收者,AlertsActivity? – Fustigador 2013-04-08 10:55:00
如果我沒有錯,並且是的,我正在嘗試在預定義的時間設置通知,我正在詢問廣播接收器。 – Kanth 2013-04-08 10:58:09