Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it mandatory to have broadcast receiver as a separate file?
    primarykey
    data
    text
    <p>I have declared an activity and a broadcast receiver in my manifest file, however, I have the code for <code>onReceive()</code> in my activity as a separate public class. When I try to trigger a broadcast from the adb command line I get a <code>classnotfound</code> error. </p> <p>My question is, is it mandatory to have the <code>broadcastreceiver</code> as a separate class in a separate file ?</p> <pre><code> @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityAsDialogActivity.this.requestWindowFeature(Window.FEATURE_NO_TITLE); : : } public class TestEmail extends BroadcastReceiver{ @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(MYINTENT)){ Log.d("Manju ==&gt;","ActivityAsDialogActivity, Got the intent"+MYINTENT); Toast.makeText(context, "Don't panik but your time is up!!!!.", Toast.LENGTH_LONG).show(); }//end of if statment }//end of onReceiver }//end of Broadcast }//end of class ActivityAsDialogActivity </code></pre> <p>below is manifest file</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.mot.activityasdialog" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="15" /&gt; &lt;application android:icon="@drawable/ic_launcher" android:label="@string/app_name" &gt; &lt;activity android:name=".ActivityAsDialogActivity" android:excludeFromRecents="true" android:theme="@style/EmptyActivity" android:configChanges="keyboardHidden|orientation|screenSize|uiMode"&gt; &lt;!-- android:theme="@android:style/Theme.Holo.Dialog" 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; &lt;receiver android:name="com.mot.activityasdialog.ActivityAsDialogActivity.TestEmail" android:enabled="true"&gt; &lt;intent-filter&gt; &lt;action android:name="com.mot.MANJU"&gt;&lt;/action&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre>
    singulars
    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.
 

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