2012-11-01 27 views
0

我正在開發兩個Android應用程序。 第一個從活動中調用廣播接收器。 第二個包含從第一個應用程序調用的廣播接收器。單獨項目中的Android BroadcastReceiver

我已經設法做廣播呼叫,當它在同一個應用程序與呼叫者的活動。 但是,當我把接收器分開項目它不起作用。我應該改變什麼?

+0

庵...將您的代碼附加到問題m中幫助。 – jsmith

+0

我相信這是你需要的。 http://stackoverflow.com/questions/2749893/how-to-use-broadcast-receiver-in-different-applications-in-android –

回答

0

這是我如何註冊接收器:

<receiver 
     android:name=".TestReceiver" 
     android:enabled="true" 
     android:exported="true" 
     android:process=":deltaFO"> 
     <intent-filter> 
      <action android:name="android.intent.action.BOOT_COMPLETED"/> 
      <action android:name="com.myapp.intent.action.FILE_OPERATION" /> 
     </intent-filter> 

    </receiver> 

這是我送的意圖

Intent intent = new Intent("com.myapp.intent.action.FILE_OPERATION"); 
     intent.putExtra("operation", operation); 
     context.sendBroadcast(intent); 

這是一流的接收意向:

public class TestReceiver extends BroadcastReceiver{ 
public final String TAG="TestReceiver"; 

@Override 
public void onReceive(Context context, Intent intent) { 
    Log.i(TAG,"EXTERNAL BROADCAST..."); 

} 

}

相關問題