android - building a notification

1)Create a Notification Builder: specify the UI content and actions

NotificationCompat.Builder mBuilder =
   
new NotificationCompat.Builder(this)
   
.setSmallIcon(R.drawable.notification_icon)
   
.setContentTitle("My notification")
   
.setContentText("Hello World!");


2)Define the Notification's Action

Intent resultIntent = new Intent(this, ResultActivity.class);
...
// Because clicking the notification opens a new ("special") activity, there's
// no need to create an artificial back stack.
PendingIntent resultPendingIntent =
   
PendingIntent.getActivity(
   
this,
   
0,
    resultIntent
,
   
PendingIntent.FLAG_UPDATE_CURRENT);


3)Set the Notification's Click Behavior

PendingIntent resultPendingIntent;
...
mBuilder
.setContentIntent(resultPendingIntent);


---------------
2.android - timepicker change theme
timepickermode in xml attribute
2-1)timpicker get AM_PM: timpicker에서 받아온 시간이 이미 24hour format이기 때문에 AM_PM을 받지 않고도 pendingintent를 만들 수 있음

댓글

이 블로그의 인기 게시물

포트란?

안드로이드 스마트폰 연결