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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:29:56+00:00 2026-05-27T02:29:56+00:00

I’ve encountered a problem after I set set my text in Android. Well the

  • 0

I’ve encountered a problem after I set set my text in Android. Well the scenario goes like this:

I use putExtra from one of my classes then starts intent. on the Second class I declared a String variable which will catch the Extra the code is:

String playername = " ";
String emailaddress = " ";

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gamepage);

    playername = getIntent().getStringExtra("pname");
    Log.v(TAG, "Player name set to : " + playername);
    emailaddress = getIntent().getStringExtra("eadd");
    Log.v(TAG, "Email set to : " + emailaddress);
    TextView playerName = (TextView)findViewById(R.id.playerName);
        Log.v(TAG, "view fetched");

I used Logs to track the passing of data and it seems to work fine but after adding the part of playerName.setText(playername);

the problem now begins and error logs shows this:

 11-22 16:30:50.271: WARN/dalvikvm(4621): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621): FATAL EXCEPTION: main
11-22 16:30:50.397: ERROR/AndroidRuntime(4621): java.lang.RuntimeException: Unable to start activity ComponentInfo{arc.android.memorygame/arc.android.memorygame.SetGameScreen}: java.lang.NullPointerException
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.os.Looper.loop(Looper.java:123)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.app.ActivityThread.main(ActivityThread.java:4627)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at java.lang.reflect.Method.invokeNative(Native Method)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at java.lang.reflect.Method.invoke(Method.java:521)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at dalvik.system.NativeStart.main(Native Method)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621): Caused by: java.lang.NullPointerException
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at arc.android.memorygame.SetGameScreen.onCreate(SetGameScreen.java:29)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
11-22 16:30:50.397: ERROR/AndroidRuntime(4621):     ... 11 more

Is there’s a problem with my code? why does it returns Null Pointer Exception?

  • 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-27T02:29:57+00:00Added an answer on May 27, 2026 at 2:29 am

    Probably playername is null after this line:

    playername = getIntent().getStringExtra("pname");
    

    getStringExtra will return null if no string value is found.

    Try something like this:

    playername = getIntent().getStringExtra("pname");
    if (playername == null)
        playername = "some default value";
    

    Later edit:

    If you are absolutely certain that playername is not null at that point, it means that findViewById returned null for some reason (a typo, an error in your xml or whatever).

    And, by the way, if you have logs and can check for yourself if a variable is null or not, why don’t you do it instead of asking? A NullPointerException is not that hard to track down, especially when you only have a few variables.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string

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.