2013년 3월 12일 화요일

android Notificiation inboxstyle addline

context().getString(R.string.denial_msg)
.length();

Display display = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
@SuppressWarnings("deprecation")
int textWidth = display.getWidth() / TextSize;

String[] events = new String[textWidth];// Sets a title for the Inbox style
for (int i = 0; i < textWidth; i++) {
if((float)(i+1)*textWidth > (float)(display.getWidth() / TextSize;
events[i] = context().getString(R.string.msg).substring(i*textWidth, (i+1)*textWidth);
else
events[i] = context().getString(R.string.msg).substring(i*textWidth);
inboxStyle.addLine(events[i]);
}

화면 크기에 맞게 텍스트 나누어서 뿌려주는 걸 만들어 봄. error군.


void notifykndroidlinaialNotification() {
Intent intent = new Intent("com.apple.app.linaial.count.reset");
PendingIntent pi = PendingIntent.getBroadcast(
kContextManager.getkContext(), 1, intent,
PendingIntent.FLAG_ONE_SHOT);

NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();

inboxStyle.setBigContentTitle(kContextManager.getkContext()
.getString(R.string.kndroid));

int textLength = kContextManager.getkContext().getString(R.string.linaial_msg)
.length();

Display display = ((WindowManager) kContextManager
.getkContext().getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();

int lineLength = 38;

int lines = textLength / lineLength + 1;

String[] events = new String[lines];

android.os.Debug.waitForDebugger();

try {
for (int i = 0; i <=lines ; i++) {
if(i*lineLength+lineLength < textLength)
events[i] = kContextManager.getkContext()
.getString(R.string.linaial_msg)
.substring(i*lineLength, i*lineLength + lineLength);
else
events[i] = kContextManager.getkContext()
.getString(R.string.linaial_msg)
.substring(i*lineLength);
inboxStyle.addLine(events[i]);
}
} catch (Exception e) {
e.printStackTrace();
}

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
kContextManager.getkContext())
.setSmallIcon(android.R.drawable.btn_star)
.setContentTitle(
kContextManager.getkContext().getString(
R.string.kndroid))
.setContentText(
kContextManager.getkContext().getString(
R.string.linaial_msg))
.setAutoCancel(true)
.setNumber(0)
.setContentIntent(pi)
.setStyle(inboxStyle)
.setLights(0, 0, 0)
.setTicker(
kContextManager.getkContext().getString(
R.string.linaial_msg))
.setUsesChronometer(true);

mBuilder.setStyle(inboxStyle);

notificationManager.notify((int) 9999, mBuilder.build());
}

짜다보니 이런코드

변수도 좀 깔끔하게 빼주고 해야 하는데

동작만 되면 okay... 이젠... 이렇게 변하는구나.


댓글 2개:

  1. 조만간 쓸일이 올거 같네요

    지금 계산기 만들고 잇어요 ㅋㅋㅋㅋㅋㅋ

    아오 이벤트 ㅡㅠ

    답글삭제
  2. 고생하는 동생~~잘하고 있구만~기특띠링똥~~

    답글삭제

국정원의 댓글 공작을 지탄합니다.

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...