Hosein
Hosein

Reputation: 493

simple jump to another page

i want to after click on my button i go to another page. but i just get error. this is my code :

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_anime_paradise_t1);

    Button list = (Button) findViewById(R.id.list);
    list.setText("List");
    list.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            Intent intent = new Intent(AnimeParadiseT1.this, View.class);
            startActivity(intent);
        }
    });

and in View class :

public class View extends Activity{
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         // TODO Auto-generated method stub
         super.onCreate(savedInstanceState);
         setContentView(R.layout.list);
     }
}

it's so strange. look at my logCat too :

08-29 00:12:32.910: D/AndroidRuntime(1582): Shutting down VM
08-29 00:12:32.910: W/dalvikvm(1582): threadid=1: thread exiting with uncaught exception (group=0x40203560)
08-29 00:12:32.920: E/AndroidRuntime(1582): FATAL EXCEPTION: main
08-29 00:12:32.920: E/AndroidRuntime(1582): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.animeparadise/android.view.View}; have you declared this activity in your AndroidManifest.xml?
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1405)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.app.Activity.startActivityForResult(Activity.java:2827)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.app.Activity.startActivity(Activity.java:2933)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at com.animeparadise.AnimeParadiseT1$1.onClick(AnimeParadiseT1.java:29)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.view.View.performClick(View.java:2506)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.view.View$PerformClick.run(View.java:9112)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.os.Handler.handleCallback(Handler.java:587)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.os.Looper.loop(Looper.java:130)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at android.app.ActivityThread.main(ActivityThread.java:3835)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at java.lang.reflect.Method.invokeNative(Native Method)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at java.lang.reflect.Method.invoke(Method.java:507)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
08-29 00:12:32.920: E/AndroidRuntime(1582):     at dalvik.system.NativeStart.main(Native Method)
08-29 00:12:34.061: I/Process(1582): Sending signal. PID: 1582 SIG: 9

and one thing more. i just define View class as an Activity.

Upvotes: 2

Views: 993

Answers (5)

Sahil Mahajan Mj
Sahil Mahajan Mj

Reputation: 11141

Put a habbit of reading Logcat carefully, The error is,

ActivityNotFoundException: Unable to find explicit activity class {com.animeparadise/android.view.View}; have you declared this activity in your AndroidManifest.xml?

This is because you havnt declared your activity in the android manifest file,

write this code in your android manifest file,

<activity
            android:name=".View"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

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

If it doesnt works, try changing the name of activity, because View is a predefined class and the name of two classes might cause the conflict..

Upvotes: 0

angarrido
angarrido

Reputation: 139

you should add something like this to your AndroidManifest file:

<activity
    android:name = ".View"
    android:label="my new Activity" >
</activity>

Also i suggest you to change the name of your acivity, because View is a very import class on Android (View).

Hope it helps!

Upvotes: 1

quietmint
quietmint

Reputation: 14153

08-29 00:12:32.920: E/AndroidRuntime(1582): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.animeparadise/android.view.View};

Check your import statements. View is an existing class in Android (android.view.View). You probably need to use the full name of your View class (e.g., com.animeparadise.View.class or whatever) when you create your Intent.

Also, as others have suggested, you should rename your activity to avoid this confusion and adhere to the common practice of ending the class name with the word Activity (e.g., ViewActivity).

Upvotes: 3

Jochem
Jochem

Reputation: 2994

[EDIT]

android.view.View already exists. That is what is going wrong (hence the 'android.view.View' part in the error): the class creating the intent is including the wrong View class.

Simply rename your View class to whatever. And press CTRL-SHIFT-O to fix your imports ;)

(And ensure your AndroidManifest.xml includes <activity android:name=".WhateverClassNameYouChose"/> in the <application> section.

Upvotes: 2

Numair
Numair

Reputation: 1062

Add your class to your AndroidManifest.xml file, like

 <activity
            android:name=".View"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

OR

Check this link

Upvotes: 1

Related Questions