Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7008791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:46:51+00:00 2026-05-27T21:46:51+00:00

So in my main activity I added an image button and it works fine.

  • 0

So in my main activity I added an image button and it works fine. When I went to add another one I started getting force closes. I linked it to a new activity and put the new activity in the manifest file. If I delete the code of the second image button and run the app it works fine. My splash screen is actually my main activity but I don’t think that’s the problem. Thanks in advance for any help you can give me.

MainActivity (New):

   package com.crazycastles;


import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;



public class MainActivity extends Activity implements OnClickListener {
    /** Called when the activity is first created. */

    @Override

    public void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        WindowManager.LayoutParams.FLAG_FULLSCREEN);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        //CREATE BUTTON 1 & SOUND
        final MediaPlayer buttonSound = MediaPlayer.create(
                MainActivity.this, R.raw.swords);

        ImageButton button1 = (ImageButton) findViewById(R.id.button1);
        button1.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                buttonSound.start();
                startActivity(new Intent(MainActivity.this,
                        button1Activity.class));
            }
        }); 
        ImageButton multiplayerbutton = (ImageButton) findViewById(R.id.multiplayerbutton);
        multiplayerbutton.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                buttonSound.start();
                startActivity(new Intent(MainActivity.this,
                        multiplayerbuttonActivity.class));
            }
        }); 

        //END OF BUTTON1 & SOUND



        }
    public void onClick(View v) {
        // TODO Auto-generated method stub

    }

    }

Manifest File:

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

    <uses-sdk android:minSdkVersion="3"></uses-sdk>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>

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


        <activity
            android:name=".SplashScreen"
            android:label="Crazy Castles" 
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:screenOrientation="landscape"
            android:configChanges="keyboard|keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

        <activity android:name="MainActivity" 
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
            android:launchMode="standard" 
            android:permission="android.permission.WAKE_LOCK"
            android:configChanges="keyboard|keyboardHidden|orientation">
        </activity>
        <activity android:name="button1Activity" 
           android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
            android:launchMode="standard" 
            android:permission="android.permission.WAKE_LOCK"
            android:configChanges="keyboard|keyboardHidden|orientation"
            android:screenOrientation="portrait"></activity>

        <activity android:name="multiplayerbuttonActivity" 
           android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
            android:launchMode="standard" 
            android:permission="android.permission.WAKE_LOCK"
            android:configChanges="keyboard|keyboardHidden|orientation"
            android:screenOrientation="portrait"></activity>



        </application>

</manifest>

SplashScreen:

package com.crazycastles;

import java.io.IOException;

import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.Window;
import android.view.WindowManager;

public class SplashScreen extends Activity {

    /**
     * The thread to process splash screen events
     */
    private Thread mSplashThread;    

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
        WindowManager.LayoutParams.FLAG_FULLSCREEN);

        // Splash screen view
        setContentView(R.layout.splash);
        final MediaPlayer buttonSound = MediaPlayer.create(
                SplashScreen.this, R.raw.swords);

        final SplashScreen sPlashScreen = this;   

        // The thread to wait for splash screen events
        mSplashThread =  new Thread(){
            @Override
            public void run(){
                try {
                    synchronized(this){
                        // Wait given period of time or exit on touch
                        wait(3000);
                        buttonSound.prepare();
                    }
                }
                catch(InterruptedException ex){                    
                } catch (IllegalStateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                finish();

                // Run next activity
                Intent intent = new Intent();
                intent.setClass(sPlashScreen, MainActivity.class);
                startActivity(intent);
                stop();                    
            }
        };

        mSplashThread.start();        
    }

    /**
     * Processes splash screen touch events
     */
    @Override
    public boolean onTouchEvent(MotionEvent evt)
    {
        if(evt.getAction() == MotionEvent.ACTION_DOWN)
        {
            synchronized(mSplashThread){
                mSplashThread.notifyAll();
            }
        }
        return true;
    }    
} 

New LogCat:

    01-01 19:51:35.068: E/MediaPlayer(12462): prepareAsync called in state 8
01-01 19:51:35.427: E/AndroidRuntime(12462): FATAL EXCEPTION: main
01-01 19:51:35.427: E/AndroidRuntime(12462): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.crazycastles/com.crazycastles.MainActivity}: java.lang.ClassCastException: android.widget.ImageView
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2737)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2753)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.app.ActivityThread.access$2500(ActivityThread.java:129)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2107)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.os.Looper.loop(Looper.java:143)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.app.ActivityThread.main(ActivityThread.java:4701)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at java.lang.reflect.Method.invokeNative(Native Method)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at java.lang.reflect.Method.invoke(Method.java:521)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at dalvik.system.NativeStart.main(Native Method)
01-01 19:51:35.427: E/AndroidRuntime(12462): Caused by: java.lang.ClassCastException: android.widget.ImageView
01-01 19:51:35.427: E/AndroidRuntime(12462):    at com.crazycastles.MainActivity.onCreate(MainActivity.java:41)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-01 19:51:35.427: E/AndroidRuntime(12462):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2701)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:46:51+00:00Added an answer on May 27, 2026 at 9:46 pm

    01-01 18:25:59.553: E/global(11497): Deprecated Thread methods are not supported.

    This pretty much tells the whole story. Have a look at the Thread class documentation and see which methods are deprecated. Check if you are using one or more of them and remove them from your code¹. The doc also states a reason why those methods should not be used.

    ¹ e.g. you are using the deprecated method Thread.stop()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two activities, one is main and I have another activity called Test
i have main activity in which i have Four menus. and i have one
I have a design of activities like this I have one main activity and
In one Android activity I have added a context menu to an ImageView with
I am using Button in main Activity. When i clicked this button it will
I had to explicitly add my import R to my main activity's source. However,
My current application has one Activity, the main one which extends ListActivity (listview of
My application was running fine until i added the following code to add an
Being frustrated about fragment behavior, I started doing some testing. I have one activity
The main activity includes some variables with set values. I created a sub-activity with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.