-1

the purpose of this activity/program is to simply switch from this activity to another one using a button. From IzzynActivity to notes. Here is the android manifest:

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

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="izzy.n.IzzynActivity"
            android:label="@string/app_name" >
            <activity
                android:name="izzy.n.notes"
                android:label="@string/notes"></activity>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

And here is the IzzynActivity.java code:

package izzy.n;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;


public class IzzynActivity extends Activity{

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button wg = (Button) findViewById(R.id.button1);
        wg.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent myIntent = new Intent(IzzynActivity.this, notes.class);
                IzzynActivity.this.startActivity(myIntent);
            }

        });
    }
}
Izzy Nakash
  • 177
  • 2
  • 2
  • 12

5 Answers5

1

For one you have an activity tag inside another activity tag in your manifest which is clearly wrong.

kabuko
  • 36,028
  • 10
  • 80
  • 93
1

An activity cannot contain another activity in the AndroidManifest.xml file. Here's the right code:

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="izzy.n.IzzynActivity"
            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="izzy.n.notes"
            android:label="@string/notes"></activity>
    </application>

</manifest>

Note:

If you return anything with setResult() from a started activity you should start it using startActivityForResult.

For the warning message:

Just edit one piece of code and re-run your application. It will be reinstalled on the phone and you should not see the warning message again.

papaiatis
  • 4,231
  • 4
  • 26
  • 38
  • Check the LogCat. Does it say anything weird when you press the button? – papaiatis Feb 29 '12 at 07:25
  • izzyn] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=izzy.n/.IzzynActivity } [2012-02-29 02:28:40 - izzyn] ActivityManager: Warning: Activity not started, its current task has been brought to the front – Izzy Nakash Feb 29 '12 at 07:28
  • public class notes extends Activity{ /** Called when the activity is first created. */ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.notes); Button wg = (Button) findViewById(R.id.button2); wg.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { Intent intent = new Intent(); setResult(RESULT_OK, intent); finish(); } }); } } – Izzy Nakash Feb 29 '12 at 07:32
  • Check this: http://stackoverflow.com/questions/3781182/activity-not-started-its-current-task-has-been-brought-to-the-front – papaiatis Feb 29 '12 at 07:33
  • Everything runs fine,until i actually ask for it to go to a diff xml page – Izzy Nakash Feb 29 '12 at 07:36
  • Just edit one piece of code and re-run your application. It will be reinstalled on the phone and you should not see the warning message again. – papaiatis Feb 29 '12 at 07:41
  • Nothing changed, but thanks! Ill try to get to it in the morning thanks for the help. – Izzy Nakash Feb 29 '12 at 07:45
0

</activity> closing tag for your first activity should come before starting tag for your second activity. You are nesting your activities, which is not permitted.

Shashank Kadne
  • 7,993
  • 6
  • 41
  • 54
0

Change your manifest to this:

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

    <uses-sdk android:minSdkVersion="10" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >

        <activity
            android:name=".IzzynActivity"
            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=".notes"
                android:label="@string/notes">
        </activity>

    </application>    
</manifest>
Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
0
<activity
            android:name="izzy.n.IzzynActivity"
            android:label="@string/app_name" >
            <activity
                android:name="izzy.n.notes"
                android:label="@string/notes"></activity>
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

you are declareing an activity inside another activity without closing first one: so replace this block with:

<activity
            android:name="izzy.n.IzzynActivity"
            android:label="@string/app_name" >

   <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

            <activity
                android:name="izzy.n.notes"
                android:label="@string/notes"></activity>
            <intent-filter>
jeet
  • 29,001
  • 6
  • 52
  • 53