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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:40:18+00:00 2026-06-19T03:40:18+00:00

Good day every body ! I’m a beginner in android development and I have

  • 0

Good day every body !

I’m a beginner in android development and I have some troubles when I switch from my second activity to my third one : I got a force clause caused by a NullPointerExeception in the onCreate function in the third one. I read the stack trace and I figured out that my problem come from the line 60 in my second activity.

name_server = thisIntent.getExtras().getString("ip");

I don’t understand why and so I don’t know how to fix it :/

Here are sources :

First activity :

package Smart.Wifi.Mote.v2;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.Gravity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SmartWifiMotev22 extends Activity 
{

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) 
{

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);        


    /**********************************
           Clic sur "connexion"
    **********************************/
    OnClickListener clic = new OnClickListener()
    {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub

            // déclaration de la nouvelle fenêtre
            // @1 : fenêtre actuelle
            // @2 : nouvelle fenêtre
            Intent newpage = new Intent(SmartWifiMotev22.this, mainActivityv22.class);
            System.out.println("lancement fenêtre");

            // récupération de la valeur contenue dans la zone de texte (adresse ip)
            EditText a_IP = (EditText) findViewById(R.id.T_IP);
            String adresse_IP = a_IP.getText().toString();

            System.out.println("adresse_IP : " + adresse_IP);


            // ajout des valeurs à l'intent (fenêtre)
            newpage.putExtra("ip", adresse_IP);

            startActivity(newpage); // lancement de la fenêtre
                    }


    } //


} // 

The second one :

package Smart.Wifi.Mote.v2;

import java.io.IOException;
import java.net.Socket;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.TextView.OnEditorActionListener;

public class mainActivityv22 extends Activity 
{

public String name_server = null;
public Socket s = null;
public String message = null;

public float startXPosition;
public float startYPosition;
public float endXPosition;
public float endYPosition;
public int moveX, moveY;

public Thread cThread;
public Thread sendThread;
public Thread alive;
public Intent thisIntent;
public boolean stopconnection = false;

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);

    thisIntent = getIntent();

    // récupération de l'adresse IP envoyé en paramètre via intent.putExtra()
    name_server = thisIntent.getExtras().getString("ip");
    System.out.println("adresse page2 : " + name_server);
} // public void onCreate(Bundle savedInstanceState) 

public boolean onCreateOptionsMenu(Menu menu) 
{
    //Création d'un MenuInflater qui va permettre d'instancier un Menu XML en un objet Menu
    MenuInflater inflater = getMenuInflater();
    //Instanciation du menu XML spécifier en un objet Menu
    inflater.inflate(R.menu.menu, menu);

    return true;
 }

   //Méthode qui se déclenchera au clic sur un item
  public boolean onOptionsItemSelected(MenuItem item) 
  {
     //On regarde quel item a été cliqué grâce à  son id et on déclenche une action
     switch (item.getItemId()) 
     {
        case R.id.Internet:
            //((TextView)findViewById(R.id.texte)).setText("Option"); 
            break;

        case R.id.Presentation:
            Intent intent_presentenation = new Intent(mainActivityv22.this, Presentationv22.class);
            startActivity(intent_presentenation);               
            break;


     }
     return true;
  }

And the last one :

package Smart.Wifi.Mote.v2;

import android.os.Bundle;
...
import android.widget.ImageButton;

public class Presentationv22 extends mainActivityv22
{

@Override
protected void onCreate(Bundle savedInstanceState) {
    System.out.println("Activity Presentation §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§");
    System.out.println("Constructeur classe mère");
    super.onCreate(savedInstanceState);
    System.out.println("Affichage");
    setContentView(R.layout.presentation);

    /*********************************
           Appui sur Start
    *********************************/
    OnClickListener Start = new OnClickListener()
    {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub              
        }
    };

    ImageButton start = (ImageButton) findViewById(R.id.ibStart);
    start.setOnClickListener(Start);

    /*********************************
          Appui sur Stop
    *********************************/
    OnClickListener Stop = new OnClickListener()
       {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
        }
    };

    ImageButton stop = (ImageButton) findViewById(R.id.ibStop);
    stop.setOnClickListener(Stop);

        }


        /**********************************
                       Menu
        **********************************/
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.menu, menu);
            return true;
        }
    }

Thanks for your help 🙂

P.S : the stack trace

02-19 16:54:43.085: I/System.out(16968): Activity Presentation §§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§
02-19 16:54:43.085: I/System.out(16968): Constructeur classe mère
02-19 16:54:43.095: D/AndroidRuntime(16968): Shutting down VM
02-19 16:54:43.095: W/dalvikvm(16968): threadid=1: thread exiting with uncaught exception (group=0x2aac8578)
02-19 16:54:43.105: E/AndroidRuntime(16968): FATAL EXCEPTION: main
02-19 16:54:43.105: E/AndroidRuntime(16968): java.lang.RuntimeException: Unable to start activity ComponentInfo{Smart.Wifi.Mote.v2/Smart.Wifi.Mote.v2.Presentationv22}: java.lang.NullPointerException
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.os.Looper.loop(Looper.java:130)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.app.ActivityThread.main(ActivityThread.java:3701)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at java.lang.reflect.Method.invokeNative(Native Method)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at java.lang.reflect.Method.invoke(Method.java:507)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at dalvik.system.NativeStart.main(Native Method)
02-19 16:54:43.105: E/AndroidRuntime(16968): Caused by: java.lang.NullPointerException
02-19 16:54:43.105: E/AndroidRuntime(16968):    at Smart.Wifi.Mote.v2.mainActivityv22.onCreate(mainActivityv22.java:60)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at Smart.Wifi.Mote.v2.Presentationv22.onCreate(Presentationv22.java:19)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-19 16:54:43.105: E/AndroidRuntime(16968):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
02-19 16:54:43.105: E/AndroidRuntime(16968):    ... 11 more
  • 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-19T03:40:19+00:00Added an answer on June 19, 2026 at 3:40 am

    Your third activity calls super.onCreate() which means mainActivityv22’s onCreate() is being called where it tries to get the extra String from the Intent. But there isnt any because this activity, the third activity wasnt started with an intent that has one.

    You should remove the super.onCreate() from your third activity and then try.

    Also I dont really know why you extended mainActivityv22. It wouldve been simpler to just extend Activity. I cant see any code that you’re reusing.

    EDIT:

    As Sam pointed out , I was wrong. Checking for null in mainActivityv22‘s onCreate() would be your best bet then.

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

Sidebar

Related Questions

I have to download some content from a website every day so I figure
Good day, I try to start new Activity from another. But it always crashed.
Good Day, I have tried good google searches, and even some reading, but not
Good day. I have an app that has one main activity which holds 3
Good day, I have some problem with my GridView. public View getView(int position, View
I've read that It's a good experience to use a fresh image every day
Good day, I have a class that implements the LoaderCallbacks, and hence have the
Good day I have a custom TextBox that has a IndicatorTextBox.ui.xml file as well
Good day, I have like 15 images I need to be buttons. I have
Good day every one! In general, my question is about time function in php/mysql,

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.