2013-04-08 54 views
1

我有一個創建一個Notification,其中日期已過,爲String,通過putExtra,這樣一個ServicePutExtras改變我的日期?

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時調用的ActivityAlertsActivity

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」,我不知道爲什麼。這讓我瘋狂!

任何人都有同樣的問題?謝謝!

+0

你可以顯示你的接收器類嗎? – Kanth 2013-04-08 10:53:55

+0

你是什麼意思接收機類?通知的接收者,AlertsActivity? – Fustigador 2013-04-08 10:55:00

+0

如果我沒有錯,並且是的,我正在嘗試在預定義的時間設置通知,我正在詢問廣播接收器。 – Kanth 2013-04-08 10:58:09

回答

0

我解決它,這樣做簡單:

String fechafinal=format.format(d).toString(); 

爲什麼,如果我Log.i它顯示的罰款,並在沒有它不是的ToString()方法來分配,這是我無法理解。