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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:20:13+00:00 2026-05-26T23:20:13+00:00

This is my codes below. I’m trying to use intent to call another activity

  • 0

This is my codes below. I’m trying to use intent to call another activity in my pack “Register” in this activity “PictureTakeActivity”. I have another button in this activity, which uses intent to call camera.
The program always stop when I try to call Register.class by clicking the button “GotoRegister”. I’ve added “Register” activity in the manifest.

in DDMS:

Unable to instantiate activity
ComponentInfo{Picture.Capture/Picture.Capture.Register}:
java.lang.NullPointerException

11-21 20:39:08.057: E/AndroidRuntime(539): FATAL EXCEPTION: main
11-21 20:39:08.057: E/AndroidRuntime(539): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{Picture.Capture/Picture.Capture.Register}: java.lang.NullPointerException
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.ActivityThread.access$600(ActivityThread.java:122)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.os.Handler.dispatchMessage(Handler.java:99)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.os.Looper.loop(Looper.java:137)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.ActivityThread.main(ActivityThread.java:4340)
11-21 20:39:08.057: E/AndroidRuntime(539):  at java.lang.reflect.Method.invokeNative(Native Method)
11-21 20:39:08.057: E/AndroidRuntime(539):  at java.lang.reflect.Method.invoke(Method.java:511)
11-21 20:39:08.057: E/AndroidRuntime(539):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-21 20:39:08.057: E/AndroidRuntime(539):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-21 20:39:08.057: E/AndroidRuntime(539):  at dalvik.system.NativeStart.main(Native Method)
11-21 20:39:08.057: E/AndroidRuntime(539): Caused by: java.lang.NullPointerException
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.Activity.findViewById(Activity.java:1794)
11-21 20:39:08.057: E/AndroidRuntime(539):  at Picture.Capture.Register.<init>(Register.java:31)
11-21 20:39:08.057: E/AndroidRuntime(539):  at java.lang.Class.newInstanceImpl(Native Method)
11-21 20:39:08.057: E/AndroidRuntime(539):  at java.lang.Class.newInstance(Class.java:1319)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
11-21 20:39:08.057: E/AndroidRuntime(539):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
11-21 20:39:08.057: E/AndroidRuntime(539):  ... 11 more

Can anyone help me find the problem?

I’m new to android. How can we debug android program efficiently when using android emulator? Thank you very much.

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);    
    final Button cameraButton = (Button)findViewById(R.id.camera_button); 
    // Get a handle to the button so we can add a handler for the click event 
    cameraButton.setOnClickListener(new OnClickListener(){
        @Override
        public void onClick(View v){
              String iString = Integer.toString(i+100);
              Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
              File file = new File("/sdcard",iString);
              outputFileUri = Uri.fromFile(file);
              intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
              startActivityForResult(intent, TAKE_PICTURE);
              i++;
           }// This will cause the onActivityResult event to fire once it's done

        });

    //Call Register.java

    Button GotoRegister = (Button) findViewById(R.id.GotoRegister);

}

public void registerhandler(View view)
{
    Intent GoRegister = new Intent(PictureTakeActivity.this,Register.class);
          startActivity(GoRegister);
    Toast toast = Toast.makeText(this, "Hello!", Toast.LENGTH_LONG);
    toast.show();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
 if (requestCode == TAKE_PICTURE) 
  {`

    Uri imageUri = null;

    // Check if the result includes a thumbnail Bitmap
    if (data != null)
    {
      if (data.hasExtra("data")) 
      {
        thumbnail = data.getParcelableExtra("data");
        // TODO Do something with the thumbnail
        SlidingDrawer mysliding= (SlidingDrawer) findViewById(R.id.drawer);
        ImageView myimage= (ImageView) findViewById(R.id.content);
        myimage.setImageBitmap(thumbnail);
        myimage.showContextMenu();
        mysliding.open(); 
      }

    //Problem!!!! This Bitmap does not have any function!
     else {
     // TODO Do something with the full image stored
     // in outputFileUri
        SlidingDrawer mysliding= (SlidingDrawer) findViewById(R.id.drawer);
        ImageView myimage= (ImageView) findViewById(R.id.content);
        myimage.setImageURI(outputFileUri);
        mysliding.open();
        }
     }
  }
}

Register class:

public class Register extends Activity
{
public
TextView RegisterName= (TextView)findViewById(R.id.RegisterName);   
final int PICTURE_ACTIVITY = 1; 



private static int TAKE_PICTURE = 1;
@Override

public void onCreate(Bundle savedInstanceState)
{

    Bitmap bit=Picture.Capture.PictureTakeActivity.thumbnail;

    super.onCreate(savedInstanceState);
    setContentView(R.layout.register_layout);
    RegisterName.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v){

            RegisterName.clearComposingText();
        }


    });

    ImageView Registerimage= (ImageView)findViewById(R.id.RegisterPicture);

    // Relply intent from PictureTakeAcitivity and go Back

    Button GoBack=(Button)findViewById(R.id.GoBack);
    GoBack.setOnClickListener(new View.OnClickListener() {
      public void onClick(View view) {
            Intent replyIntent = new Intent();
            setResult(RESULT_OK, replyIntent);
            finish();
            AddEntry();
        }
    }

    );


}


private void AddEntry()
{
    final Button RegisterButton=(Button)findViewById(R.id.RegisterButton);
    RegisterButton.setOnClickListener
    (new OnClickListener()
     {
        @Override
        public void onClick(View v)
        {
              String EntryName=(String) RegisterName.getText();
              Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
              File file = new File(getFilesDir(),EntryName);
              Uri registryFileUri = Uri.fromFile(file);
              intent.putExtra(MediaStore.EXTRA_OUTPUT, registryFileUri);
              startActivityForResult(intent,TAKE_PICTURE);         
        }           
    }
    );

}

}

  • 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-26T23:20:14+00:00Added an answer on May 26, 2026 at 11:20 pm
    TextView RegisterName= (TextView)findViewById(R.id.RegisterName); 
    

    Can’t find the textview before you’ve loaded the layout, put it after :

    setContentView(R.layout.register_layout);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I write some jQuery codes as below: $('.button').each(function(){ $(this).click(function(){ console.log($(this)); do_sth(); }); }); var
This below codes give me error below: How to generate this codes help me
Look please below this codes throw me : FormatException was unhandled by user code
i am using this code below to dynamically capture the name of the button
I have this code below. As you can see I am passing two variables
I have this javascript code below that uses jquery, it is suppoed to be
i have the codes below class ReservationController extends Zend_Controller_Action { public function init() {
What is the correct way to use signal handlers? I saw the codes below
i have 2 void functions(trying to implement radio button), i want them to send
I got this error when trying to use parameters to my sql statement, but

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.