2011-12-19 63 views
1

在标准Android通知的右下角,我不会看到时间(例如12:00),而不是像这样的模式:11/1/16。总是有3个数字被“/”所忽略。有人知道这个问题吗?Android通知中的错误时间戳

回答

1

我不KHOW,你如何让你的通知,但我认为你应该使用:System.currentTimeMillis的()

例子:

package com.test; 

import android.app.Activity; 
import android.app.Notification; 
import android.app.NotificationManager; 
import android.app.PendingIntent; 
import android.content.Intent; 
import android.os.Bundle; 

public class TestActivity extends Activity { 

    private NotificationManager notificationManager; 

    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); 

     showNotification("My notification",android.R.id.text1); 
    } 

    private void showNotification(CharSequence text, int idNotify) { 
     Notification notification = new Notification(R.drawable.icon, text, System.currentTimeMillis()); 
     Intent intent = new Intent(); 
     intent.setClassName("com.test","com.test.TestActivity"); 
     PendingIntent contentIntent = PendingIntent.getActivity(TestActivity.this, 0,intent,0); 
     notification.setLatestEventInfo(this, "My Notification",text, contentIntent); 
     notification.flags |= Notification.FLAG_AUTO_CANCEL; 
     notificationManager.notify(idNotify, notification); 
    } 
} 
+0

谢谢!我将currentTimeMillis()乘以1000.这就是问题所在! – Bernd 2011-12-19 21:56:57

+0

然后你应该接受答案:) – Fildor 2011-12-20 08:49:07

+0

现在,我已经接受它:-)不知道该怎么做,因为我在这里是新的。 – Bernd 2011-12-21 17:54:00