开发者

Unable to start activity :-Explicit Intent Problem

From My splash screen I start my Main Activity class .

Main Activity contains a imagebutton from where I call other class(Second Screen) through explicit intent.

But Now after SpleshScreen time is over I got force close, but when I remove the explicit intent code of MainActivity.

After Splesh Screen.I get my MainActivity in perfect manner.>(But as i have to go in SecondScreen I put the code of explict Intent)

And I want flow like SpleshScreen->MainActivity->SecondScreen

My LogCat is showing following error

07-13 12:14:59.192: ERROR/AndroidRuntime(2455): Uncaught handler: thread main exiting due to uncaught exception
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.app/com.example.app.MainActivity}: java.lang.ClassCastException: android.widget.ImageButton
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.app.ActivityThread.performLaunchActivity(Act开发者_JAVA百科ivityThread.java:2558)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2574)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.app.ActivityThread.access$2400(ActivityThread.java:121)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1925)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.os.Looper.loop(Looper.java:136)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.app.ActivityThread.main(ActivityThread.java:4425)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at java.lang.reflect.Method.invokeNative(Native Method)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at java.lang.reflect.Method.invoke(Method.java:521)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at dalvik.system.NativeStart.main(Native Method)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455): Caused by: java.lang.ClassCastException: android.widget.ImageButton
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at com.rvappstudios.fingerslayarrr.MainActivity.onCreate(MainActivity.java:24)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2521)
07-13 12:14:59.192: ERROR/AndroidRuntime(2455):     ... 11 more
07-13 12:14:59.200: ERROR/ActivityManager(1188): SIGNAL_QUIT: to crashed process 2455

My MainActivity.java code of imagebutton to call my secondscreen

  public class MainActivity extends Activity 
{
    private Button play;

    //Called when first activity is created
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main1);

        play=(Button)findViewById(R.id.down);
        play.setOnClickListener(new OnClickListener() 
        {

            @Override
            public void onClick(View v)
            {
                Intent intent=new Intent(MainActivity.this,SecondScreen.class);

                startActivity(intent);


            }
        });

    }
}

My Menifest file code

<activity android:name=".SplashScreen"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name="MainActivity" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
   android:screenOrientation="portrait" >
   <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
  </activity>

   <activity android:name="SecondScreen" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
   android:screenOrientation="portrait" >
</activity>


Wild guess.

Caused by: java.lang.ClassCastException: android.widget.ImageButton

but you have

private Button play;
play=(Button)findViewById(R.id.down);

Do you have Button or ImageButton in xml?


Post the source code of your MainActivity and its layout.xml. Or refer line#24 in your MainActivity. There is a type mismatch.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜