I am currently working on an app that includes a splash screen with a sound. After the splash screen is done, I want it to be able to go to my Main Menu. The problem I have is that it keeps crashing after the sound is played. I've tried going on other threads having the same problem with different ways of doing it but it keeps crashing at the end of the splash screen.
Edit: When I run the app, my event log says that the app was successful and no errors are found. I ran the debugger and it says
E/ArrayAdapter: You must supply a resource ID for a TextView
D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.finalproject, PID: 12755
java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
Caused by: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView
at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:388)
I believe it must be something with my MainActivity that is causing the problem.
My Splash code:
public class SplashActivity extends AppCompatActivity {
MediaPlayer ourSound;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
Thread timer = new Thread(){
@Override
public void run(){
try {
ourSound = MediaPlayer.create(SplashActivity.this, R.raw.splashsound);
ourSound.start();
sleep(4000);
} catch (InterruptedException e){
} finally {
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
} // end finally
} // end run
};
timer.start();
} // end onCreate
@Override
protected void onPause(){
super.onPause();
ourSound.release();
} // end onPause
} // end SplashActivity
My MainActivity Code:
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
String[] mainMenu = {"Websites", "Directions", "Scheduling", "Photos"};
setListAdapter(new ArrayAdapter<String>(this, R.layout.activity_main, mainMenu));
} // end onCreate
protected void onListItemClick(ListView l, View v, int position, long id) {
switch (position) {
case 0:
startActivity(new Intent(MainActivity.this, Websites.class));
break;
case 1:
startActivity(new Intent(MainActivity.this, Directions.class));
break;
case 2:
startActivity(new Intent(MainActivity.this, Scheduling.class));
break;
case 3:
startActivity(new Intent(MainActivity.this, Photos.class));
break;
} // end switch
}// end onListItemClick
} // end MainActivity