0

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; } } 
1
  • Does it crash? If so post your logcat. Also, try calling startActivity(n); before finish() Commented Jul 24, 2013 at 15:10

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.