0

I am trying go from one activity to its sub-activity (i.e, a new page with more buttons), but every time I click the button, the application "Unfortunately stops running".

I believe that the flaw lies in the manifest where I might writing something wrong under the intent-filter section.

Mind taking a look?

public class MainActivity extends ActionBarActivity {

 Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); addListenerOnButton(); addListenerOnButton2(); } //First Activity private void addListenerOnButton() { // TODO Auto-generated method stub button = (Button) findViewById(R.id.activity_one); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { Intent IntentOne = new Intent(arg0.getContext(), ActivityOne.class); arg0.getContext().startActivity(IntentOne); } }); } //Second Activity, will look into it later. Making it Explicit for now. public void addListenerOnButton2() { button = (Button)findViewById(R.id.activity_two); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View argo) { Intent IntentTwo = new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.ca")); startActivity(IntentTwo); } }); } } 

///////////////////////////////////////////////////////

Here is the Manifest :

 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.poop" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="19" /> <application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" > <activity android:name="com.example.poop.MainActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.poop.ActivityOne" android:label="@string/app_name" > <intent-filter> <action android:name="com.example.poop.ActivityOne" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> </application> </manifest> 

I have not added ActivityTwo yet to the manifest.

2

1 Answer 1

1

You can't have Activities that aren't registered in the Manifest. I don't see an ActivityOne registered in your AndroidManifest.xml

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

3 Comments

Shoot! In the Manifest ActivityTwo is meant to be ActivityOne. Let me edit it quickly. Thanks vmagro!
Is the manifest in your question the actual manifest? What I mean is does your actual manifest list ActivityOne or ActivityTwo? If it does and still doesn't work, we will need logs to help you further.
Hello Vmagro! I slogged at the problem and eventually rebuilt the project in the images of this project right here : stackoverflow.com/questions/20382521/… Now I am trying to build a log in system that retains the user's photo, email and name! Thanks for the help! Cheers!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.