Android. Intent.ACTION CAMERA BUTTON is not working
<p>Learning broadcast messages. The book DN Kolisnichenko - "Programming for Android" is an example of where the camera at the touch of a button starts the service. But I have it che does not work. What is the problem? Or I do not know what is the camera button (physical or on the display), or do not understand what is wrong. Here is the code of the example:</p>

<p>MainActivity.java</p>

<pre><code>import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.content.IntentFilter;

public class MainActivity extends AppCompatActivity {


    MyReceiver iReceiver = new MyReceiver();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        IntentFilter iFilter =  new IntentFilter(Intent.ACTION_CAMERA_BUTTON);

        iFilter.addAction(Intent.ACTION_CAMERA_BUTTON);

        registerReceiver(iReceiver, iFilter);
    }
    @Override
    protected void onDestroy() {
        unregisterReceiver(iReceiver);
        super.onDestroy();
    }
}
</code></pre>

<p>MyReceiver.java</p>

<pre><code>import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class MyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context rcvContext, Intent rcvIntent) {
        String action = rcvIntent.getAction();

        if (action.equals(Intent.ACTION_CAMERA_BUTTON)) {

            rcvContext.startService(new Intent(rcvContext,
                    MyService.class));
        }
    }
}
</code></pre>

<p>MyService.java</p>

<pre><code>import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.widget.Toast;

public class MyService extends Service {
    @Override
    public IBinder onBind(Intent arg0) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        Toast.makeText(this,"Service started...",
                Toast.LENGTH_LONG).show();
    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        Toast.makeText(this, "Service destroyed...",
                Toast.LENGTH_LONG).show();
    }
}
</code></pre>

<p>And manifest.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.ivarious.myapplication"&gt;

    &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
    &lt;application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"&gt;
        &lt;activity android:name=".MainActivity"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
                &lt;action android:name="android.intent.action.CAMERA_BUTTON" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

        &lt;receiver android:name=".MyReceiver"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
                &lt;action android:name="android.intent.action.CAMERA_BUTTON" /&gt;
            &lt;/intent-filter&gt;
            &lt;service android:name=".MyService"&gt;&lt;/service&gt;
            &lt;action android:name="android.intent.action.CAMERA_BUTTON" /&gt;
            &lt;action android:name="android.intent.extra.KEY_EVENT" /&gt;
            &lt;uses-permission android:name="android.permission.CAMERA" /&gt;
            &lt;uses-feature android:name="android.hardware.camera" /&gt;
        &lt;/receiver&gt;



    &lt;/application&gt;

&lt;/manifest&gt;
</code></pre>