Androidでのお知らせ
1546 ワード
普通の携帯電話の上にはステータスバーがあり、バッテリーの電力量、信号の強度、着信なし、メールが表示されます.Androidの画面上にもステータスバーがあります.ここでいう通知とは,このステータスバーに通知を表示することである.
通知を送信する手順は以下の通りである:1).通知マネージャの取得
2).新しい通知を作成し、そのアイコンとタイトルを指定します.
通知を送信する手順は以下の通りである:1).通知マネージャの取得
NotificationManager mNotificationManager = (NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE);
2).新しい通知を作成し、そのアイコンとタイトルを指定します.
int icon = android.R.drawable.stat_notify_chat;
long when = System.currentTimeMillis();
// , ,
Notification notification = new Notification(icon, null, when);
Intent openintent = new Intent(this, OtherActivity.class);
// openintent
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, openintent, 0);
notification.setLatestEventInfo(this, “ ”, “ ", contentIntent);
mNotificationManager.notify(0, notification);