2013-04-08 55 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()方法来分配,这是我无法理解。