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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:57:53+00:00 2026-06-12T14:57:53+00:00

I’m using an intent and getIntent on my Android app but it crashes in

  • 0

I’m using an intent and getIntent on my Android app but it crashes in the emulator. Logcat indicates that my problem it’s a NullPointerException but since yesterday I just can’t find the solution for this problem.

Here is my Logcat:

10-05 20:27:12.053: E/AndroidRuntime(246): Uncaught handler: thread main exiting due to uncaught exception
10-05 20:27:12.063: E/AndroidRuntime(246): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.Tonos/com.example.Tonos.TonosSet}: java.lang.NullPointerException
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.os.Looper.loop(Looper.java:123)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.app.ActivityThread.main(ActivityThread.java:4363)
10-05 20:27:12.063: E/AndroidRuntime(246):  at java.lang.reflect.Method.invokeNative(Native Method)
10-05 20:27:12.063: E/AndroidRuntime(246):  at java.lang.reflect.Method.invoke(Method.java:521)
10-05 20:27:12.063: E/AndroidRuntime(246):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-05 20:27:12.063: E/AndroidRuntime(246):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-05 20:27:12.063: E/AndroidRuntime(246):  at dalvik.system.NativeStart.main(Native Method)
10-05 20:27:12.063: E/AndroidRuntime(246): Caused by: java.lang.NullPointerException
10-05 20:27:12.063: E/AndroidRuntime(246):  at com.example.Tonos.TonosSet.onCreate(TonosSet.java:21)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-05 20:27:12.063: E/AndroidRuntime(246):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
10-05 20:27:12.063: E/AndroidRuntime(246):  ... 11 more

This is my “TonosSet.java”:

package com.example.Tonos;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;


public class TonosSet extends Activity {
/**
 * @see android.app.Activity#onCreate(Bundle)
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.tonos_set);

    Intent i = getIntent();
    int position = i.getExtras().getInt("id");

    ImageView imageView = (ImageView) findViewById(R.id.full_image_view2);
    TextView textView1 = (TextView)findViewById(R.id.namesong);
    TextView textView2 = (TextView)findViewById(R.id.artist);

    switch (position){
    case 0:        
        imageView.setImageResource(R.drawable.pico);

        textView1.setText("Tone1");
        textView2.setText("Someone");        
    break;

    case 1:        
        imageView.setImageResource(R.drawable.pict);

        textView1.setText("Tone2");
        textView2.setText("Someone");           
    break;

    }


}
}

And here is the part of code that creates the Intent “i” (Tonos.java):

....            
maListViewPerso.setAdapter(mSchedule);

    maListViewPerso.setOnItemClickListener(new OnItemClickListener() {
            @Override
        @SuppressWarnings("unchecked")
        public void onItemClick(AdapterView<?> a, View v, int position, long id){
                HashMap<String, String> map = (HashMap<String, String>) maListViewPerso.getItemAtPosition(position);

                Toast.makeText(Tonos.this, "" + position, Toast.LENGTH_SHORT).show();

                Intent tonosset = new Intent(Tonos.this, TonosSet.class);
                startActivity(tonosset);

                Intent i = new Intent(getApplicationContext(), TonosSet.class);

                i.putExtra("id", position);
                startActivity(i);

            }


    });

}
}

Thanks a lot guys! =)

  • 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-12T14:57:55+00:00Added an answer on June 12, 2026 at 2:57 pm
     // First time you start TonosSet activity (without extra)
     // If you want to start TonosSet activity only once, comment two following line
     Intent tonosset = new Intent(Tonos.this, TonosSet.class);
     startActivity(tonosset);
    
     // Second time you start TonosSet activity (with extra this time)
     Intent i = new Intent(getApplicationContext(), TonosSet.class);
     i.putExtra("id", position);
     startActivity(i);
    

    You start TonosSet activity twice. First time you launch it, the intent doesn’t have extra. To resolve your problem check your intent have extra.

    Intent i = getIntent();
    int position = -1; // init with default value
    if(i.getExtras() != null)
        position = i.getExtras().getInt("id");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a small JavaScript validation script that validates inputs based on Regex. I
I am reading a book about Javascript and jQuery and using one of the

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.