나는 서비스 내부 BroadcastReceiver
있습니다동일한 브로드 캐스트 인 텐트 액션을 기반으로 두 개의 응용 프로그램에서 두 개의 BroadcastReceiver가 어떻게 든 충돌 할 수 있습니까?
public class NotificationClickService extends Service {
private static final String DEBUG_TAG = "NotificationClickService";
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
registerReceiver(NotificationClickReceiver, new IntentFilter(DownloadManager.ACTION_NOTIFICATION_CLICKED));
}
@Override
public void onDestroy() {
unregisterReceiver(NotificationClickReceiver);
}
BroadcastReceiver NotificationClickReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(DEBUG_TAG, "NotificationClickReceiver: onReceive CALLED");
Intent i = new Intent(android.app.DownloadManager.ACTION_VIEW_DOWNLOADS);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(i);
}
};
}
이 전면에 시스템 다운로드 관리자를 제공합니다.
내 전화에서 JellyBean을 기반으로하는 CyanogenMod 10.1을 실행 중입니다.
하지만 ...
는는 즉시 시스템 응용 프로그램으로 CMupdater 시작 :
- 경우 CMupdater 현재 대신
DownloadManager
, 그것은 나의 서비스의 브로드 캐스트 리시버에서 호출되어 실행되고; - CMupdater이 실행되고 있지 않지만 이 적어도 한 번으로 실행되면 수신자가 전혀 호출되지 않습니다.
다시 부팅하고 업데이터를 실행하지 않으면 다시 작동합니다. 내 타블렛에서도 해당 CyanogenMod 10.1 버전으로 테스트를 모두 마쳤습니다.
package com.cyanogenmod.updater.receiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.cyanogenmod.updater.UpdatesSettings;
public class NotificationClickReceiver extends BroadcastReceiver{
private static String TAG = "NotificationClickReceiver";
@Override
public void onReceive(Context context, Intent intent) {
// Bring the main app to the foreground
Intent i = new Intent(context, UpdatesSettings.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
context.startActivity(i);
}
}
및 매니페스트에서 :
이
은 CM의 수신기에서입니다<receiver android:name="com.cyanogenmod.updater.receiver.NotificationClickReceiver">
<intent-filter>
<action android:name="android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED"/>
<category android:name="android.intent.category.HOME"/>
</intent-filter>
</receiver>
android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED
내가 사용하는 DownloadManager.ACTION_NOTIFICATION_CLICKED
의도에 대한 상수 값입니다.
"현재 실행중인 경우 DownloadManager 대신 서비스의 BroadcastReceiver에서 호출됩니다."실행중인 항목은 무엇입니까? 뭐라고? –
질문이 수정되었습니다. 나는 그것이 지금 더 분명하기를 바란다. – dentex
확인해 주셔서 감사합니다. 따라서 당신은'ACTION_NOTIFICATION_CLICKED' 액션을 가진 수신기를 등록하고 있습니다. 사용자가 다운로드를 클릭하면 모든 수신자에게 알림이 전송됩니다. 이것은 당신과 당신을 의미합니다. 수신기가 실제로 호출되지 않았 음을 확인 했습니까? 아마도 문제는 수신자 자체 이외의 새로운 활동 시작 플래그와 관련이 있습니다. –