Skip to content Skip to sidebar Skip to footer

How To Fix App Crashing After Intent Activity Called

I'm trying to pass a variable from database(created on LoginActivity.java) when user pressing register button and pass the value to HomeActivity.java .Before I use intent extras an

Solution 1:

I guess you ask the Activity for getIntent before onCreate is called.

Try this:

Intent i;
Bundle extras;

String pname; 
int pcoins;
int pgems; 

@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    i = getIntent();
    extras = i.getExtras();

    pname = extras.getString("P_NAME");
    pcoins = extras.getInt("P_COINS");
    pgems = extras.getInt("P_GEMS");

    // follow with your onCreate code ....
}

Post a Comment for "How To Fix App Crashing After Intent Activity Called"