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

BroadcastReceiver가 묵묵부답입니다 ㅠㅠ

0 추천
    public void setAlarm() {
        AlarmManager alarmManager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(MainActivity.this, AlarmReceive.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, intent, 0);

        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.add(Calendar.MINUTE, 1);
        alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
    }

MainActivity onCreate에서 setAlram 불렀습니다.

 

public class AlarmReceive extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "Alarm", Toast.LENGTH_SHORT).show();
        Log.d("AlarmReceive","Notification");
        Intent in = new Intent(context, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, in, 0);

        NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
                .setContentTitle("타이틀")
                .setContentText("텍스트")
                .setSmallIcon(R.drawable.plus_icon)
                .setWhen(System.currentTimeMillis())
                .setContentIntent(pendingIntent)
                .setAutoCancel(true);

        manager.notify(1, builder.build());
    }
}
<receiver
    android:name=".service.AlarmReceive"
    android:process=":remote" />

매니페스트에 리시버 등록도 해놨는데..

1분이 지나도 AlarmReceive의 Log도 토스트메세지도 안뜹니다..ㅜ

이유가 뭐죠..?

+)

intent-filter도 추가해봤는데 안되고 

MainActivity에서 sendBroadcast()써서 intent보내봤는데도 안됩니다..

리시버가 묵묵부답이여요 ㅠㅠㅠㅠ

++)

동적 리시버는 아주 잘되는데 정적 리시버가 안됩니다..

그렇다면 매니페스트 문제같은데 무엇이 문제인지..

<receiver
    android:name=".AlarmReceive">
    <intent-filter>
        <action android:name="com.alarmReceive" />
    </intent-filter>
</receiver>
namu 님이 2016년 3월 6일 질문
2016년 3월 7일 수정

1개의 답변

0 추천
http://www.androidpub.com/2612483

쎄미님이 만드신 테스트입니다

이걸로 안되면 리시버문제입니다
익명사용자 님이 2016년 3월 7일 답변
...