2
A
回答
1
這是一個示例參照這一個
public class SimpleNotification extends Activity {
private NotificationManager mNotificationManager;
private int SIMPLE_NOTFICATION_ID;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mNotificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
final Notification notifyDetails = new Notification(R.drawable.android,"New Alert, Click Me!",System.currentTimeMillis());
Button start = (Button)findViewById(R.id.notifyButton);
Button cancel = (Button)findViewById(R.id.cancelButton);
start.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Context context = getApplicationContext();
CharSequence contentTitle = "Notification Details...";
CharSequence contentText = "Browse Android Official Site by clicking me";
Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
PendingIntent intent =
PendingIntent.getActivity(SimpleNotification.this, 0,
notifyIntent, android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
notifyDetails.setLatestEventInfo(context, contentTitle, contentText, intent);
mNotificationManager.notify(SIMPLE_NOTFICATION_ID, notifyDetails);
}
});
cancel.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mNotificationManager.cancel(SIMPLE_NOTFICATION_ID);
}
});
}
}
相關問題
- 1. Android:從通知欄中刪除通知
- 2. 從android通知欄中刪除通知
- 3. Android狀態欄通知
- 4. Android WebView與通知欄
- 5. Android通知欄號碼
- 6. 從通知欄在Android的
- 7. 禁用android通知欄
- 8. 清除通知欄Android
- 9. Phonegap - Android - 狀態欄通知
- 10. jQuery通知欄
- 11. 通知欄
- 12. Android狀態欄通知 - 通過任何方式通知狀態欄(烤麪包)通過狀態欄?
- 13. 如何禁用Android通知欄上的短信通知圖標?
- 14. Android的 - 保持通知持穩在通知欄
- 15. Android如何在通知欄上撰寫通知
- 16. Android的亮度變化通知(或狀態欄彙總通知)
- 17. 通知文本在Android的通知欄中不可見?
- 18. GCM通知不會顯示在通知欄中。 Android
- 19. 的Android無法隱藏通知欄
- 20. Android - 增量狀態欄通知圖標
- 21. 開始下載通知欄點擊android
- 22. 通知欄上的Android服務
- 23. Phonegap狀態欄通知,Android,iOS
- 24. 隱藏實體中的android通知欄
- 25. PhoneGap的Android狀態欄通知例如
- 26. Android - 規劃用戶欄通知
- 27. Android:靜態狀態欄通知
- 28. Android:將通知欄設置爲谷歌+
- 29. 每天更改android狀態欄通知
- 30. Android狀態欄multiline通知API 14