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 7967741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:58:15+00:00 2026-06-04T06:58:15+00:00

Could someone please explain why I’m getting the error: java.lang.RuntimeException: Unable to start activity

  • 0

Could someone please explain why I’m getting the error:

java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.project/com.project.Deals}: java.lang.IllegalStateException: System services not available to Activities before onCreate() 

When I am using the two classes below, been doing this for ages now. I appreciate the help

public class Deals extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView textview = new TextView(this);
        textview.setText("This is the Artists tab");
        setContentView(textview);

        NetworkConnection nc = new NetworkConnection();
        boolean networkAvail = nc.isNetworkConnAvail();
        if (networkAvail == true){
        }

    }
};

public class NetworkConnection extends Activity {
/** Called when the activity is first created. */

public boolean isNetworkConnAvail() {

        ConnectivityManager connMgr = (ConnectivityManager) 
            getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
        if (networkInfo != null)
            return networkInfo.isConnected();

        return false;
    }
}
  • 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-04T06:58:16+00:00Added an answer on June 4, 2026 at 6:58 am

    The problem is in your NetworkConnection class you never call onCreate try this instead:

    public boolean isNetworkConnAvail(Context context) {
    
        ConnectivityManager connMgr = (ConnectivityManager) 
            context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
        if (networkInfo != null)
            return networkInfo.isConnected();
    
        return false;
    }
    

    And call it like this from your other class:

    nc.isNetworkConnAvail(this);
    

    Or alternatively call the onCreate method of the super class in your constructor in NetworkConnection. If you are only extending Activity for the sake of being able to use getSystemService then you may as well not extend Activity and just have the Context passed through either in the constructor or in the method itself as this will then give you access to those methods 🙂

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

Sidebar

Related Questions

Could someone please explain what an I/O Error 32 refers to in the context
Could someone please explain the following compiler error to me: struct B { };
Could someone please explain to me why I'm getting an ActionView::TemplateError when I try
Could someone please explain how to simulate this error? and also what this complains
could someone please explain this java code for me. i find it really hard
Could someone please explain how to go about getting the values passed to a
Could someone please explain, when will the NoteList activity be spawned with intent actions
Could someone please explain the best way to connect to an Interbase 7.1 database
Could someone please explain? I couldn't find anything on the internet, everything talks about
Could someone please explain when would I want to use delegation instead of inheritance?

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.