I want my splash activity to support both vertical and horizontal orientation.
The code for splash activity is as follows
public class Splash extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread timer = new Thread(){
public void run() {
try{
sleep(5000);
}catch(InterruptedException e){
e.printStackTrace();
}finally{
Intent ARCActivityIntent = new Intent("com.ex.rc.LISTSCREEN");
startActivity(ARCActivityIntent);//
finish();
}
}};
timer.start();
}
}
Code of splash.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:background="@drawable/splash_bg"
>
</LinearLayout>
But the problem is – LISTSCREEN activity is re-created number of times the orientation is changed.
Help me.
I was having a similiar problem. I got it fixed. Here is the solution.
Create only one layout for splash screen, but create different images for
LANDSCAPEandPORTRAIT. As you have only one layout i.e portrait, the activity would not be re-created. But background image would change providing the effect of orientation change.Write down the following code in onCreate.
Override
onConfigurationChangedmethodSplashActivity in manifest should look like this