Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What is the package of your BroadcastReceiver class which is Main.java?</p> <pre><code>&lt;receiver android:name=".Main" &gt; &lt;intent-filter&gt; &lt;action android:name="android.content.Intent.ACTION_BATTERY_CHANGED" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; </code></pre> <p>It should not com.cy.headset right? Since it will be a conflict with your main activity which is Main.java</p> <p>I think there are two solutions on this one specify the package of your receiver in the manifest.</p> <p>example:</p> <pre><code>&lt;receiver android:name="com.package.name.Main" &gt; &lt;intent-filter&gt; &lt;action android:name="android.content.Intent.ACTION_BATTERY_CHANGED" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; </code></pre> <p>Or if you want your receiver to be at the same package of your main activity which is Main.java rename your receiver</p> <p>example: </p> <pre><code>&lt;receiver android:name=".BatteryChange" &gt; &lt;intent-filter&gt; &lt;action android:name="android.content.Intent.ACTION_BATTERY_CHANGED" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;activity android:name="com.cy.headset.Main" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre> <p>Another way to do it is.</p> <pre><code>&lt;receiver android:name="com.cy.headset.BatteryChange" &gt; &lt;intent-filter&gt; &lt;action android:name="android.content.Intent.ACTION_BATTERY_CHANGED" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;activity android:name="com.cy.headset.Main" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload