i created a splash screen but when i launch my app the splash screen does not show, just a black screen. however, after my timer for the splash screen ends, my menu comes up. in the graphical layout of my splashscreen.xml, the splash screen image show. but when run, it does not. all is normal except for my splash screen…
code for myMain.java:
package com.immrroj.firstapp;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
public class myMain extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splashscreen);
Thread splashtimer = new Thread()
{
@Override
public void run()
{
try
{
int timer = 0;
while (timer < 5000)
{
sleep(100);
timer = timer + 100;
}
startActivity(new Intent("com.immrroj.firstapp.CLEARSCREEN"));
} catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
finish();
}
}
};
splashtimer.run();
}
@Override
protected void onDestroy()
{
// TODO Auto-generated method stub
super.onDestroy();
}
@Override
protected void onResume()
{
// TODO Auto-generated method stub
super.onResume();
}
@Override
protected void onStart()
{
// TODO Auto-generated method stub
super.onStart();
}
@Override
protected void onStop()
{
// TODO Auto-generated method stub
super.onStop();
}
}
code for myMenu.java
package com.immrroj.firstapp;
import android.app.Activity;
import android.os.Bundle;
public class myMenu extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
code for my main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/mymenu">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PRESS ME!!"
android:textSize="19dp"
android:textStyle="bold"
android:width="200dp" android:layout_gravity="right"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="PRESS ME TOO!"
android:gravity="center"
android:textSize="19dp"
android:textStyle="bold" android:width="200dp" android:layout_gravity="right"/>
</LinearLayout>
code for my splashscreen.xml…. the image androidsplash is not showing
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:src="@drawable/androidsplash"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
code for my android manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.immrroj.firstapp"
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:label="@string/app_name"
android:name=".myMain" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:label="@string/app_name"
android:name=".myMenu" >
<intent-filter >
<action android:name="com.immrroj.firstapp.CLEARSCREEN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
please help..although i can continue, it is really bugging me….
UPDATE:
okay… i think its really hard to fix this without having hands on the code… so im posting this link so anybody can see the codes and tinker it… please help me… i wnat to learn android but im stuck in here…. download source code here, it’s safe i swear: https://skydrive.live.com/redir.aspx?cid=79ecba5b079a1b4c&resid=79ECBA5B079A1B4C!293&parid=79ECBA5B079A1B4C!113&authkey=!AK8-cta_tThQUms
Got it.
Downloaded your .rar and gave it a look. Turns out there was something wrong with your
Thread. I don’t know exactly what, but it was causing the layout not to be properly loaded (probably because you made it sleep for 100 ms, then wake up, check a variable, and sleep again for 100 ms over and over).I changed your thread with the following code and now it works perfectly on my phone:
You can leave all the other
onStart, onPause etcmethods out, you’re not using those in a splash screen anyway.I uploaded the edited code here: Download
Good luck with your app!