1
在標準Android通知的右下角,我不會看到時間(例如12:00),而不是像這樣的模式:11/1/16。總是有3個數字被「/」所忽略。有人知道這個問題嗎?Android通知中的錯誤時間戳
在標準Android通知的右下角,我不會看到時間(例如12:00),而不是像這樣的模式:11/1/16。總是有3個數字被「/」所忽略。有人知道這個問題嗎?Android通知中的錯誤時間戳
我不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);
}
}
謝謝!我將currentTimeMillis()乘以1000.這就是問題所在! – Bernd 2011-12-19 21:56:57
然後你應該接受答案:) – Fildor 2011-12-20 08:49:07
現在,我已經接受它:-)不知道該怎麼做,因爲我在這裏是新的。 – Bernd 2011-12-21 17:54:00