Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:12:36+00:00 2026-06-05T14:12:36+00:00

I have declared an activity and a broadcast receiver in my manifest file, however,

  • 0

I have declared an activity and a broadcast receiver in my manifest file, however, I have the code for onReceive() in my activity as a separate public class. When I try to trigger a broadcast from the adb command line I get a classnotfound error.

My question is, is it mandatory to have the broadcastreceiver as a separate class in a separate file ?

     @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 ==>","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

below is manifest file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mot.activityasdialog"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".ActivityAsDialogActivity"
             android:excludeFromRecents="true"
             android:theme="@style/EmptyActivity"
             android:configChanges="keyboardHidden|orientation|screenSize|uiMode">
             <!-- android:theme="@android:style/Theme.Holo.Dialog"
             android:label="@string/app_name" -->

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <receiver android:name="com.mot.activityasdialog.ActivityAsDialogActivity.TestEmail" android:enabled="true">
           <intent-filter>
               <action android:name="com.mot.MANJU"></action>
           </intent-filter>
        </receiver>

    </application>

</manifest>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:12:38+00:00Added an answer on June 5, 2026 at 2:12 pm

    Short answer: Yes it needs to be a different Class. And in a separate file.

    Long answer: Since your BroadcastReceiver must be a subclass of BroadcastReceiver and your Activity must be a subclass of Activity and Java does not allow multiple inheritance and Activity and BroadcastReceiver are not related in a suitable fashion. Yes, it has to be two classes.

    It seems to have to be in its own file too. I tried it and the system cannot find the BroadcastReceiver if it is an inner class. public or not.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that is inside my Activity class to load and save a
I have an activity which is declared in my manifest with android:noHistory=true , and
I have created Broadcast receiver <receiver android:name=.IncomingBroadcastReceiver> <intent-filter> <action android:name=android.intent.action.PHONE_STATE></action> </intent-filter> </receiver> declared it
I have this intent in the manifest file: <activity android:name=.ProductStrategyActivity android:label=@string/product_strategy_header /> I get
I have declared an enum in my server code, and would like my client
I have a ContentProvider which is declared in the Manifest, when is it really
I need to have a class with one activity that is performed once per
in my application I call startActivityForResult( new Intent(this, ShowPreferencesActivity.class), <some code>); the activity is
I have written a few Android apps, and have always declared a starting Activity
I have declared a string in my strings.xml file , and using it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.