MyReceiver.java
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(final Context context, final Intent intent) {
Log.i("MyReceiver", "MyAction received!");
}
}
В AndroidManifest.xml
(под тегом application
)
<receiver android:name=".MyReceiver">
<intent-filter>
<action android:name="MyAction" />
</intent-filter>
</receiver>
MainActivity.Java
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sendBroadcast(new Intent("MyAction"));
}
}
Метод MyReceiver.onReceive
никогда не запускается. Я что-то пропустил?