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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:17:51+00:00 2026-05-28T01:17:51+00:00

I have a one android class which extends Activity. public class MainAct extends Activity{

  • 0

I have a one android class which extends Activity.

 public class MainAct extends Activity{
        Context context;
        SourceJava srcClass;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            context = this; 
            System.out.println("inside oncreate");
            setContentView(R.layout.main);
            srcClass = new SourceJava();
        }
    }

I have another Java class as like below and which this is calling from MainAct class.

public class SourceJava {       
    public SourceJava(){
        System.out.println("inside constructor***");
        MyClass myClass = new MyClass();            
    if(myClass != null){
    System.out.println("**not null");
    myClass.powerOff();

      }

   }       
 }

In the SourceJava I am calling another class. i.e

 public class MyClass extends Activity{ 

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            // TODO Auto-generated method stub
            super.onCreate(savedInstanceState);
            System.out.println("**inside myclass");
            powerOff();
        }

        public void powerOff(){
            System.out.println("**inside powerOff");
            Intent call = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:5555")); 
            startActivity(call);
        }

    }
  }

I am getting NullPointerException on line startActivity(call),
myClass.powerOff(); and
srcClass = new SourceJava();
what is the problem with this code?

  • 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-28T01:17:52+00:00Added an answer on May 28, 2026 at 1:17 am

    You are treating MyClass (which is an Activity class) as regular Java class. The MyClass activity is neither registered nor loaded so call to startActivity is pointless here. To do so you need to pass reference of Context to the SourceClass and MyClass via constructors.

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

Sidebar

Related Questions

I have an Activity calling a Service defined in IDownloaderService.aidl: public class Downloader extends
I have created an abstract class FbActivity, which extends Activity to connect to facebook
I have one activity which download data from the web. In middle of the
I am using fragments to show images/pages.I have one Activity(Main) which contains all the
I have two threads in an Android application, one is the view thread, and
I understand most Android devices have a 16mb limit (24mb on Nexus One) on
I have one std::list<> container and these threads: One writer thread which adds elements
I have one application which uses the standard .NET forms authentication cookie, now I
i have a grid view which contain images when click on one image it
I have a View in Android that has an onTouchEvent which stores the x

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.