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

  • Home
  • SEARCH
  • 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 3426320
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:42:03+00:00 2026-05-18T06:42:03+00:00

I am developing an application in Android and have an issue where Android framework

  • 0

I am developing an application in Android and have an issue where Android framework throws java.lang.InstantiationException upon trying to instantiate a nested class.
Here is the scenario.

  1. Class A extending Activity with nested class B which extends BroadcastReceiver:

    public class A extends Activity
    {
        public void onCreate(){
        ....};
        //Class B
        public class B extends BroadcastReceiver
        {
            public void onReceive(...)
        }
    }
    
  2. Class declarations in manifest file :

    ….

Sorry for the bad indentation. Just couldn’t find a way of properly indenting the code with so many tags.

  1. Broadcast from a service :

    Intent updateIntent = new Intent();
    updateIntent.setAction("desired_action");
    sendBroadcast(accountPropertyUpdateIntent);

With all the above given things, the code gets compiled, but when run on the device, after the broadcast is called, i get a InstantiationException saying cannot instantiate pacakage.A$B, and dalvik says no found.

Now this whole scenario works on Android 2.2, but somehow this fails on 2.1.

I don’t know exactly what is happening. Am in need of help. Maybe something basic is missing by me.

Can anyone please help me? Thanks in advance.

  • 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-05-18T06:42:04+00:00Added an answer on May 18, 2026 at 6:42 am

    Finally got a logical conclusion about the whole scenario myself. Was dumb enough not to read the <receiver> documentation on developer.android.net.
    It clearly stated that there are two way for an application to get the broadcast.

    There are two ways to make a broadcast receiver known to the system: 
    One is declare it in the manifest file with this element. 
    The other is to create the receiver dynamically in code and register it with the
    Context.registerReceiver() method. 
    See the BroadcastReceiver class description for more on dynamically created receivers.
    

    I am using both the methods.
    My scenario should have failed on 2.2 as well, as those receivers were registered through manifest too and they should have been called automatically, but somehow it didn’t ( This still remains a mystery ).

    Removed all the receivers from manifest and just kept the dynamic registration of broadcast receivers and now the code works just like before only without the exceptions.

    Thanks for all the help. 🙂

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

Sidebar

Related Questions

No related questions found

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.