2013-07-18 1 views
0

액티비티를 시작하고 중지해야하는 애플리케이션이 있습니다.빈 인 텐트 필터로 인해 문제가 발생합니다.

지금까지 활동을 시작해도 좋습니다.

활동을 중지하려고하면 문제가 발생합니다.

는 활동을 종료 의도를 방송 그 알람 관리기입니다 :
 Intent ftue = new Intent(ctxt, VideoActivty.class); 
     ftue.putExtra("finish", true); 
     PendingIntent pftue = PendingIntent.getBroadcast(ctxt, 0, ftue, 0); 
     Calendar calSet4 = Calendar.getInstance(); 
     calSet4.set(Calendar.MONTH, c.get(Calendar.MONTH)); 
     calSet4.set(Calendar.YEAR, c.get(Calendar.YEAR)); 
     calSet4.set(Calendar.DAY_OF_WEEK, 3); 
     calSet4.set(Calendar.HOUR_OF_DAY, hftue); 
     calSet4.set(Calendar.MINUTE, mftue); 
     calSet4.set(Calendar.SECOND, 0); 
     calSet4.set(Calendar.MILLISECOND, 0); 

     //calSet.setTimeZone(TimeZone.getTimeZone("UTC")); 
     mgr.setRepeating(AlarmManager.RTC_WAKEUP, calSet4.getTimeInMillis(), 
       7 * 24 * 60 * 60 * 1000, pftue); 

그리고 나는 Activty를 종료해야 브로드 캐스트 리시버를 구현 한 내 Activty에서

.

@Override 
public void onResume() { 
super.onResume(); 
IntentFilter f=new IntentFilter(); 
registerReceiver(receiver, f); 
} 


@Override 
public void onPause() { 
unregisterReceiver(receiver); 
super.onPause(); 
} 

BroadcastReceiver receiver=new BroadcastReceiver() { 
    public void onReceive(Context context, Intent intent) { 
     Log.e("","intento ricevuto"); 
     if(intent.getBooleanExtra("finish",false))finish(); 

    } 
}; 

내 응용 프로그램은 방송 의도를받지 않으며, 나는 텐트 필터가 비어 있기 때문에 즉 이해합니다.

브로드 캐스트를 수신하려면 어떻게 의도 필터를 구현해야합니까?

감사!

+0

또한 활동이 일시 중지 된 경우 방송을 수신하지 않습니다. –

답변

1

인 텐트 필터가 비어있는 이유는 무엇입니까? 당신은 어떤 문자열로 의도 행동을 쓸 수 있습니다 (그러나 그것은해야하지 SDK 작업에 존재)

//

같은
IntentFilter f = new IntentFilter("com.android.INTENT_ACTION_TO_CLOSE_ACTIVITY"); 

을 그리고 당신이 할 때, 조건에

Intent mIntent = new Intent("com.android.INTENT_ACTION_TO_CLOSE_ACTIVITY"); 
sendBroadcast(mIntent); 

를 사용 활동을 닫으십시오.

+0

@Thanks a lot !!!!!! –

+0

가장 환영합니다 –

+0

당신과 무슨 일이 일어 났는지 알아? –