//푸시로 받은 메세지
if(intent.getAction().equals("com.google.android.c2dm.intent.RECEIVE")){
msg = intent.getExtras().getString("msg");
msg2 = intent.getExtras().getString("msg2");
msg2 = URLDecoder.decode(msg2);
}
푸시로 메세지를 이렇게 받고
Handler h = new Handler(Looper.getMainLooper());
h.post(new Runnable() {
public void run() {
//토스트로 푸시된 메세지 띄우기
Toast.makeText(GCMIntentService.this, "show Toast...."+msg + " " + msg2, Toast.LENGTH_SHORT).show();
//진동주기
Vibrator vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
long milliseconds = 1000;
vibrator.vibrate(milliseconds);
//화면켜기
PowerManager powerManager = (PowerManager) context.getSystemService( Context.POWER_SERVICE );
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(
PowerManager.SCREEN_DIM_WAKE_LOCK |
PowerManager.ACQUIRE_CAUSES_WAKEUP
, "TEST_1" );
/* 10초 동안 화면 및 cpu 활성화 */
wakeLock.acquire( 10000 );
//상태바 공지
NotificationManager nm = (NotificationManager) context.getSystemService( Context.NOTIFICATION_SERVICE );
Notification notification = new Notification(R.drawable.ic_launcher, "새글등록" + msg2, System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, new Intent( context, tam.Taxi.TamsTaxi.MainActivity.class ), 0);
notification.setLatestEventInfo(context, "새글등록", msg, pendingIntent);
//해당 메세지 선택시 상태바 아이콘 삭제
notification.flags = Notification.FLAG_AUTO_CANCEL;
nm.cancel( 0 );
nm.notify( 0, notification );
}
});
이렇게 메세지를 상태창에 등록하고 클릭하면 사라지고 메인 엑티비티가 뜨게 했습니다
그런데 메세지를 여러번 받았을 경우 그동안 받은 메세지를 배열이나 리스트에 쌓아놨다가 상태표시줄에 있는 아이콘 클릭시 그동안 쌓여있는 메세지를 다 보여줬으면 합니다
카톡같은 경우에는 메세지가 몇개 쌓여있는지 숫자를 보여주고 마지막 메세지를 짧게 보여주던데
숫자를 카운트 할수 있다면 그동안 받은 메세지도 쌓아놓을수 있지 않을가하는데...
방법을 몰라서요 고수님들 도와주세요~~~
ㅠ.ㅠ