2012-12-14 2 views
-1

알림 표시 줄 (매일 2 이벤트)이 있습니다. 문자열 배열의 작은 목록, 임의의 숫자와 아래 코드를 가져 오는 메서드입니다.상태 표시 줄 알림 이벤트를 클릭하십시오.

이벤트를 클릭하고 해당 활동 (not1 [x])에서 문자열 변수 show를 사용하여 새 활동을 열 수 있습니다.

어떻게하면 되나요?

random();

String ns = Context.NOTIFICATION_SERVICE; 
     NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(ns); 
     int icon = R.drawable.ic_launcher2; 
     CharSequence tickerText = not1[x]; 
     long when = System.currentTimeMillis(); 
     Notification notification = new Notification(icon, tickerText, when); 
     CharSequence contentTitle = "Title"; 
     CharSequence contentText = not1[x];; 
     Intent notificationIntent = new Intent(); 
     PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); 
     notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent); 
     final int HELLO_ID = 1; 
     mNotificationManager.notify(HELLO_ID, notification); 

답변

1

은 당신의 코드

Intent notificationIntent = new Intent(context,yourActivityclass); 
    PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0); 

을 Chagne 그냥 문자열

Intent i = new Intent(); 
i.putExtra("key", stringValue); 

Intent other = new Intent() 
other.getStringExtra(key) 
+0

쿨의 코드를 사용! 질문 : "stringValue"내 코드에서 배열입니다 : not1 [x]. 코드가 맞습니까? –

+0

예 This code is correct 이것은 의도 intent.purExtra ("key", char [])가있는 intent에 인 텐트를 보낼 수있는 예제입니다. –

+0

감사합니다! 다른 클래스 (Notify.class)에서 : Intent other = new Intent(); other.getStringExtra (key); 어떻게 "키"를 정의합니까? varible 좋아해? –

관련 문제