The onReceive () broadcast receiver never called

I get this problem in ICS, but not in previous versions:

From App1, I send a broadcast and try to get it in App 2. But onReceive is never called in App 2 activity.

I can’t understand what this onReceive block called, although I correctly specified everything.

First run BroadcastReceive, and then BroadcastSend

Any help that helps me solve this problem is greatly appreciated.

Submission operation App1

public class BroadcastSend extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent i = new Intent();
    i.setAction("edu.ius.rwisman.custom.intent.action.TEST");
    i.putExtra("url","ww.ius.edu");
    sendBroadcast(i);
}

Receive operation App 2

public class BroadcastReceive extends BroadcastReceiver{
// Display an alert that we've received a message.    
@Override 
public void onReceive(Context context, Intent intent){
    System.out.println("Inside onReceive");
    String url = intent.getExtras().getString("url");
    Toast.makeText(context, "BroadcastReceive:"+url, Toast.LENGTH_SHORT).show();
  }

Application Manifest 2

<?xml version="1.0" encoding="utf-8"?>

  

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <receiver android:name="edu.ius.rwisman.BroadcastReceive.BroadcastReceive" android:enabled="true" android:exported="true"> 
        <intent-filter>
            <action android:name="edu.ius.rwisman.custom.intent.action.TEST"/>
        </intent-filter>
    </receiver>
</application>

+5
source share
1 answer

ICS , . Android 3.1+ , . . , Intent.FLAG_INCLUDE_STOPPED_PACKAGES, .

i.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
+10

All Articles