NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.notification_icon).setContentTitle("Event tracker").setContentText("Events received")
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
String[] events = new String[6];// Sets a title for the Inbox style big view
inboxStyle.setBigContentTitle("Event tracker details:"); // Moves events into the big view
for (int i=0; i < events.length; i++) {
inboxStyle.addLine(events[i]);
}
// Moves the big view style objec0t into the notification object.mBuilder.setStyle(inBoxStyle);
구글 메뉴얼에는 이렇게 나와 있다.
구식은 이렇다.
if (null == computerManager) {
Log.d(TAG, "pu null");
return;
}
Intent intent = new Intent("com.count.reset");
PendingIntent pi = PendingIntent.getBroadcast(
ContextManager.getContext(), 1, intent,
PendingIntent.FLAG_ONE_SHOT);
if (null == mmegicomputer) {
Log.d(TAG, "Making computer here");
mmegicomputer = new Notificaiton();
mmegicomputer.icon = android.R.drawable.btn_star;
mmegicomputer.when = System.currentTimeMillis();
mmegicomputer.flags = computer.FLAG_AUTO_CANCEL;
mmegicomputer.tickerText = "droid";
// mmegicomputer.contentIntent = pi;
mmegicomputer.setLatestEventInfo(
ContextManager.getContext(), "droid",
ContextManager.getContext().getString(R.string.msg)+
++deniedCount
+ "count", pi);
} else
return;
computerManager
.notify((int)1234, mmegicomputer);
이부분
if (null == mmegicomputer) {
부터 노티피케이션을 만든다.
Notificaiton mmergicomputer = new Notification();
이 만드는 코드.
일단 Notification 객체 인스턴스를 만들면 그 내부의 멤버변수들에게
이런저런 설정을 해주고.
notificationManager를 통하셔 뿌려준다.
NotificationManager computerManager ;
이런거지
NotificaitonManger는 안드로이드 떠 있을 동안 하나밖에 없을 테니 싱글톤
클레스 일 것이다.
그래서
컨텍스트.getSystemService(
Context.NOTIFICATION_SERVICE);
로 새롭게 만드는게 아니라 얻어 와야 한다.(인스턴스 없으면 싱글톤에서 알아서 만들겠지)
그런데 이 방식은 구식이다.
새로운 노티는 (시간 지나면 이것도 더 이상 새롭지 않겠지만)
computerManager
.notify((int)1234, mmegicomputer);
가 아니라.
computerManager.notify((int)1234, mmegicomputer.build());
와 같이 변화 된다.
그래서 만드는 방식도 new Notification이 아니라.
NotificationCompat.Builder mmegicomputer= new NotificationCompat.Builder(blahblah.getContext())
.setSmallIcon(android.R.drawable.btn_star)
.setContentTitle("Event tracker")
.setContentText("Events received")
.setAutoCancel(true)
.setNumber(0)
.setContentIntent(pi)
.setStyle(inboxStyle)
.setLights(0, 0, 0)
.setTicker("wewefe")
.setUsesChronometer(true);
이렇게 바뀌었다.
가만보면 별로 바뀐게 없는데 영문 메뉴얼 보다보면 겁나 많이 바뀐 것처럼 설명해 놓았다.
노티보면 커졌다 작아 졌다도 된다.
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
String[] events = new String[6];// Sets a title for the Inbox style
// big view
events[0] = "Event tracker";
events[1] = "Events received";
events[2] = "ffggggggaefawefweaf";
events[3] = "ffggggggaefawefweaf";
events[4] = "ffggggggaefawefweaf";
events[5] = "ffggggggaefawefweaf";
for (int i = 0; i < events.length; i++) {
inboxStyle.addLine(events[i]);
}
요렇게 만들고
mmegicomputer.setStyle(inboxStyle);
요렇게 추가해 주면 펼쳤을 때는 쟤가 보인다.
2013년 3월 7일 목요일
피드 구독하기:
댓글 (Atom)
UPBIT is a South Korean company, and people died of suicide cause of coin investment.
UPBIT is a South Korean company, and people died of suicide cause of coin. The company helps the people who control the market price manipu...
-
프루나는 이제 믿을만한 공유가 안되고 있다. 젠장. 영화 다운 받아보면 전부 야동이나 포르노류 밖에는 없다. 신고되어 있는 자료부터 보지만 신고가 안되어 있는 것은 제대로 다운도 되지 않는다. 이젠 유료 사이트를 믿을 수 밖엔... ...
-
SELinux 불린 값을 이용해서 SELinux.getBooleanValue("xxxx") SELinux.setBooleanValue("xxxx", yyyy); Policy 에도 if 문을 줄...
-
간만에 아침에 운동 갔다가 일하고 나서 피곤한 몸을 이끌고 쓰고 있다. 새벽 4시 50분에 일어났는데 나도 모르게 운동을 하러 나가게 되었다. 막 전역 했을 때 28인치던 내 허리가 지금은 36에 육박한다. 우스운 것이 배만 ...
댓글 없음:
댓글 쓰기
국정원의 댓글 공작을 지탄합니다.