marco quezada
marco quezada

Reputation: 29

Android App switching activities

I've been working on my first true Android app for a few weeks, and I've been running into a bit of a problem. My app utilizing the Eclipse with the Android ADK can connect to a database that I have on a site, but when it tries to move towards the next activity it doesn't work. What is the problem?

Login.Java snippet:

   success = json.getInt(TAG_SUCCESS);
            if (success == 1) {
                Log.d("Login Successful!", json.toString());
                Intent n = new Intent(Login.this, ReadComments.class);
                finish();
                startActivity(n);
                return json.getString(TAG_MESSAGE);

ReadComments.class snippet:

public class ReadComments extends Activity{

 @Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.read_comments);
}




@Override
public boolean onCreateOptionsMenu(Menu menu)
{
super.onCreateOptionsMenu(menu);
menu.add("Register")
    .setIntent(new Intent(this,Register.class));
menu.add("New Reservation")
    .setIntent(new Intent(this, NewReservation.class));
menu.add("About Luxury Parking")
.setIntent(new Intent(this, Aboutus.class));
return true;


}

}

Upvotes: 0

Views: 103

Answers (2)

wdziemia
wdziemia

Reputation: 1459

You are calling finish() before you call startActivity(n); Calling finish() will destroy the activity, hence the other activity not starting. Also don't forget to declare it within your manifest file.

Upvotes: 1

Mete
Mete

Reputation: 2884

Probably the reason is manifest xml file changes.

Here is a sample, enter this under application tag ;

<activity android:name="mete.gcm.info" android:theme="@style/AppTheme"></activity>      

mete.gcm is my folder name (under src folder) info is my activity name.

Upvotes: 0

Related Questions