마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Notification 클릭시 액티비티가 실행되지 않습니다.

0 추천

onPause 시 Notification 을 세팅하고, onResume 시 사라지게는 했습니다.

그런데 Notification 을 클릭해도, 설정한 activity 가 실행되지 않고 있습니다.

Notification 설정하는 부분 입니다.

public void showNotification()
{
        NotificationManager mNotiManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        
        Intent intent = new Intent(this, MainMenuActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, 0);
        
        Notification.Builder builder = new Notification.Builder(this);
        builder.setSmallIcon(R.drawable.icon_noti).setTicker("APP").setWhen(System.currentTimeMillis());
        builder.setContentText("APP is running");
        builder.setContentTitle("APP");
        builder.setContentIntent(pi);
        
        Notification notification = builder.getNotification();
        mNotiManager.notify(NOTI_ID, notification);
}

아래는 Notification 클릭 시Warning 로그 메시지 입니다.

W/KeyguardViewMediator(389): verifyUnlock called when not externally disabled
W/InputMethodManagerService(389): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@42ffbe30 attribute=null, token = android.os.BinderProxy@435b93a0

답변 부탁 드립니다.

감사합니다.

허저업 (670 포인트) 님이 2013년 5월 2일 질문

2개의 답변

0 추천
 
채택된 답변

자답입니다.

PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, 0);

이 부분을

PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0);

이렇게 수정했더니 실행이 되었습니다.

허저업 (670 포인트) 님이 2013년 5월 2일 답변
0 추천
Зима в Буковелі — це класика, але літо там теж варте уваги. Цього літа вирішив поїхати в гори без лиж, і поки готувався, натрапив на сайт, де зібрано реально корисну інфу про відпочинок у цьому регіоні в теплу пору року.
 
Там є детальні гайди по горах, маршрути, поради, що робити і куди йти, коли сніг уже розтанув. Окремо відзначу матеріал про озеро Молодості — все по ділу, без води, з конкретними порадами. Усе без води, по суті, з практичними рекомендаціями.
 
Якщо плануєте поїздку в Карпати цього літа або просто хочете подивитися на знайомий курорт з іншого боку — зайдіть, точно знайдете пару ідей. Корисні матеріали зібрані на цьому сайті: [url=https://bukovelnaideya.space/]bukovelnaideya.space[/url]
 
Думаю, буде корисно. Легких мандрівок!
Arthurnak 님이 2일 전 답변
...