4

I've just started learning Android apps programming, i'm following the android official basics tutorials but i don't understand why i'm having an error while i make an intent and the app throws me this error.

public class MainActivity extends ActionBarActivity {

    public static final String EXTRA_MESSAGE = "com.panagetstudios.androidapp.MESSAGE";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void sendMessage(View view){
        Intent inte = new Intent(this, DisplayMessageActivity.class);
        EditText edittext = (EditText) findViewById(R.id.edit_message);
        String text = edittext.getText().toString();
        inte.putExtra(EXTRA_MESSAGE, text);
        startActivity(inte);
    }

}

This is my manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.panagetstudios.androidapp"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".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=".DisplayMessageActivity"
        android:label="@string/title_activity_display_message" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.panagetstudios.androidapp.MainActivity" />
        </activity>

    </application>

</manifest>

Please help me i'm lost, i can provide you more information if necessary.

Regards

Roman Panaget
  • 1,578
  • 12
  • 21

3 Answers3

0

You should have the full package name for your activity:

<activity
    android:name="com.panagetstudios.androidapp.DisplayMessageActivity"
    android:label="@string/title_activity_display_message" >
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.panagetstudios.androidapp.MainActivity" />
    </activity>

also, make sure your activity lives in the folder src/com.panagetstudios.androidapp

Bengerman
  • 821
  • 7
  • 7
0

Try this

<activity
    android:name=".DisplayMessageActivity"
    android:label="@string/title_activity_display_message" >
    <intent-filter>
            <action android:name="android.intent.action.DISPLAY" />

            <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
Viswanath Lekshmanan
  • 9,945
  • 1
  • 40
  • 64
0

It's ok guys, i've just found the solution. I've just execute Eclipse as the administrator and restart my project and it works correctly, thank you for your collaboration

Roman Panaget
  • 1,578
  • 12
  • 21