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 7806123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:25:56+00:00 2026-06-02T02:25:56+00:00

I am developing an app in which i had used splash screen. But after

  • 0

I am developing an app in which i had used splash screen. But after splash disappears, then
Next screen becomes black before switching to my main activity and I don’t want black screen. Can anyone please suggest me how to do this?
Here’s my code.

Launcher Activity

public class MainActivity extends Activity{
public static final String TAG = "MainActivity";
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Intent in = new Intent(getApplicationContext(), SplashScreenActivity.class);
synchronized (this) {
try {
wait(50);
} catch (InterruptedException e) {
String str = e.toString();
Log.d(TAG, str);
}//catch
}//synchronized block
startActivity(in);
}//onCreate
}//class

SplashScreenAcitvity

public class SplashScreenActivity extends Activity {
private Thread splashThread;
public static final String TAG = "SplashScreenActivity";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
final SplashScreenActivity splashScreen = this;

splashThread = new Thread(){
public void run(){
try {
synchronized (this) {
wait(3000);
}
} catch (Exception e) {
String str = e.toString();
Log.d(TAG, str);
}
finish();
Intent in = new Intent();
in.setClass(splashScreen, ProjectActivity.class);
startActivity(in);
stop();
}//run
};
splashThread.start();
}//onCreate

}//class

Project Activity
This is the class from where main operation will start.

public class ProjectActivity extends TabActivity {
static int x=0;
static int color;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.tabxml);

if(x==1)
{
Dor.c=1;
color = getIntent().getExtras().getInt("color");
//Intent in=new Intent();
//in.putExtra("color",color);
}
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost();  // The activity TabHost
TabHost.TabSpec spec;  // Resusable TabSpec for each tab
Intent intent;  // Reusable Intent for each tab
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, Dor.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("dor").setIndicator("Dor",
res.getDrawable(R.drawable.ic_tab_artists))
.setContent(intent);
tabHost.addTab(spec);

// Do the same for the other tabs
intent = new Intent().setClass(this, Album.class);
spec = tabHost.newTabSpec("albums").setIndicator("Albums",
res.getDrawable(R.drawable.ic_tab_album)
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Forhandler.class);
spec = tabHost.newTabSpec("forhandler").setIndicator("Forhandler",
res.getDrawable(R.drawable.ic_tab_forhandler))
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, Diplomat.class);
spec = tabHost.newTabSpec("diplomat").setIndicator("Diplomat",
res.getDrawable(R.drawable.ic_tab_diplomat))
.setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}

I tried with async task but it didn’t worked. Here’s my modified code:

ProjectStart

public class ProjectStart extends AsyncTask<Context, Void, Void>{
public static final String TAG = "ProjectStart";
/*public ProjectStart() {
    super("ProjectStart");
    // TODO Auto-generated constructor stub
}*/

Context ctx;
public ProjectStart(Context context){
    this.ctx = context;
}//constructor

@Override
protected Void doInBackground(Context... params) {
    // TODO Auto-generated method stub
    Intent in = new Intent();
    in.setClass(ctx, ProjectActivity.class);
    Log.d(TAG, "doInBackground called");
    return null;
}//doInBackground

/*@Override
protected void onHandleIntent(Intent intent) {
    // TODO Auto-generated method stub
    Intent in = new Intent();
    in.setClass(getApplicationContext(), ProjectActivity.class);
    startActivity(in);
    Log.d("Project Start", "onHandleIntentCalled");
}*/

}//class

In SplashScreen.java I did following modifications

splashThread = new Thread() {
        public void run(){
            try {                   
                synchronized (this) {
                    wait(3000);
                }//synchronized
            }//try  
            catch(InterruptedException e) {} 
            finally {
                finish();
                new ProjectStart(sPlashScreen).execute();
                /*Intent in = new Intent(getApplicationContext(), ProjectStart.class);
                startService(in);*/
                stop();
            }//finally
            Log.d(TAG, "run method called");
        }//run
    };

And, here is stack trace:

  04-19 11:29:02.181: E/AndroidRuntime(341): FATAL EXCEPTION: Thread-8
04-19 11:29:02.181: E/AndroidRuntime(341): java.lang.ExceptionInInitializerError
04-19 11:29:02.181: E/AndroidRuntime(341):  at abc.com.camera.SplashScreen$1.run(SplashScreen.java:32)
04-19 11:29:02.181: E/AndroidRuntime(341): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
04-19 11:29:02.181: E/AndroidRuntime(341):  at android.os.Handler.<init>(Handler.java:121)
04-19 11:29:02.181: E/AndroidRuntime(341):  at android.os.AsyncTask$InternalHandler.<init>(AsyncTask.java:421)
04-19 11:29:02.181: E/AndroidRuntime(341):  at android.os.AsyncTask$InternalHandler.<init>(AsyncTask.java:421)
04-19 11:29:02.181: E/AndroidRuntime(341):  at android.os.AsyncTask.<clinit>(AsyncTask.java:152)
04-19 11:29:02.181: E/AndroidRuntime(341):  ... 1 more


    04-19 11:29:02.181: E/AndroidRuntime(341): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

I am not getting what is the problem.

  • 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-06-02T02:25:58+00:00Added an answer on June 2, 2026 at 2:25 am

    I think the Best solution for you is asynctask

    Given is an example from Developer’s site. Asynctask has main four Methods.

    onPreExecute()
    
    doInBackground(Params...)
    
    onProgressUpdate(Progress...)
    
    onPostExecute(Result)
    

    And this is other Example.

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

Sidebar

Related Questions

Im developing an App which is going to be used on Samsung Galaxy SII
i am developing an app which has a evernote integration,everything works perfect but my
I am developing an app which gets outgoing SMS content through content resolver but
I'm developing an app which will allow me to post on Facebook. But I
I'm developing an app which has a large amount of related form data to
I am developing an app which requires the phone to ring or make some
I am developing an app which listens to incoming sms. I have added the
I am currently developing an app which will be on Android Market. How can
I'm developing an app which requires the system to get the touch events even
I am developing an app which uses a accelerometer + compass sensor and I

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.