1

시간이 카운트 다운되는 앱이 있습니다. 시간이 다가 오면 알림 바에서 알림을 받고 싶습니다.알림 표시 줄을 통해 앱에 입장 할 수 없습니다.

이미 이런 짓을 한 : 나는 알림을 클릭하여 응용 프로그램을 입력 할 때

Intent intent = new Intent(); 
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); 
Notification noti = new Notification.Builder(this).setTicker("Ticker Title").setContentTitle("Content Title").setContentText("Notification content.").setSmallIcon(R.drawable.iconnotif).setContentIntent(pIntent).getNotification(); 
noti.flags=Notification.FLAG_AUTO_CANCEL; 
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
notificationManager.notify(uniqueID, noti); 

문제가 발생합니다. 알림이 표시되면이를 클릭하지만 아무 것도하지 않습니다.

이 문제를 해결하는 방법은 무엇입니까? 도움 주셔서 감사합니다! :)

+0

Google에 "알림으로부터의 Android 활동 열기"를 시도하셨습니까? – Eran

답변

1

귀하의 통지에는 PendingIntent가 있습니다. 이것은 통지를 클릭하는 동작을 정의하는 데 사용됩니다. 보류중인 인 텐트에는 의도가 있으며,이 인 텐트에는 시작할 애플리케이션 또는 일반적으로 알림을 클릭 한 후 수행 할 작업에 대한 정보가 포함됩니다. 당신의 예에서

, 그러나, 당신의 보류 의도에 포함 된 의도는 다음과 같습니다

// Empty intent, not doing anything 
Intent intent = new Intent(); 

일예 당신의 의도는 무엇을 해야할지를 정의하지 않습니다. 의도를 다음과 같이 변경하십시오.

// New Intent with ACTION_VIEW: 
Intent intent = new Intent(Intent.ACTION_VIEW); 

// Activity to launch 
intent.setClassName("your.package.name", "ActivityToLaunch"); 

// Intent Flags 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);