2012-05-08 6 views
2

이 문제와 관련하여 많은 스택 오버 플로우 게시물을 발견했지만 Notification.Builder 클래스를 사용하는 대신 사용되지 않는 알림 메서드를 모두 사용합니다.상태 표시 줄 알림에서 활동이 시작되지 않음

상태 표시 줄 알림을 성공적으로 만들었지 만 클릭하면 아무 일도 발생하지 않습니다. 로그 캣에서 경고가 표시됩니다 :

public class LunchNotificationBuilder { 

private Notification notification; 
public LunchNotificationBuilder(Lunch lunch, Context context) { 
    Builder builder = new Builder(context); 
    Calendar reminderTime = (Calendar)lunch.getReminderTime().clone(); 
    builder.setWhen(reminderTime.getTimeInMillis()); 
    builder.setTicker("Reminder for " + lunch.getTitle()); 
    builder.setContentTitle("LunchBunch Notification"); 
    builder.setContentText("Upcoming lunch at " + lunch.getTitle()); 
    builder.setSmallIcon(R.drawable.ic_launcher); 
    Intent intent = new Intent(context, InviteDetails.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_ONE_SHOT)); 
    this.notification = builder.getNotification(); 
} 

public Notification getNotification() { 
    return this.notification; 
} 

} 

점심 클래스는 내가 만든 단순한 데이터 구조입니다, 걱정하지 마십시오 여기

Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stu[email protected] 

내가 내 알림을 구축하기 위해 사용하고 코드입니다 그.

전달되는 컨텍스트는 Application.getApplicationContext()입니다.

문서에서 제안한대로 Intent.FLAG_ACTIVITY_NEW_TASK 플래그를 설정하고 있으며 PendingIntent에 PendingIntent.FLAG_ONE_SHOT 플래그가 있습니다.

다른 메모 : 코드에서 startActivity를 명시 적으로 호출 할 때 내가 시작하려고하는 작업 (InviteDetails)이 제대로 작동합니다. 이 PendingIntent 비즈니스가 작동하지 않습니다.

+0

getActivity에서 다른 requestCode를 전달하려고합니다. [이것은 A2.3 에뮬레이터에서 작동합니다.] (http://pastebin.com/Qa983XfB) 그러나 원하는 것은 아닐 수도 있습니다. – Deucalion

답변

0

나는 밖으로 안드로이드를 사용하는 방법을 모르겠다. 클릭하기 전에 전체 알림을 보려면 아래로 드래그하지 말고 상단의 상태 표시 줄을 클릭했습니다. 내 코드가 작동했다. doh!

관련 문제