coderMint
coderMint

Reputation: 65

Android Intent Declaration troubles

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.

Upvotes: 0

Views: 235

Answers (1)

vmagro
vmagro

Reputation: 181

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

Upvotes: 1

Related Questions