I am using below code from one of my activity to start another
Intent viewIntent = new Intent(getApplicationContext (), landingPage.class);
Bundle b = new Bundle();
b.putString("ApplicationName", a_Bean.getApplicationName());
if (landingPage.getInstanceCount() < 1)
bp.landingPage_ProgressDialog = ProgressDialog.show(ViewAllApp.this, "Please wait...", "Retrieving data...", true, false);
viewIntent.putExtras(b);
viewIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(viewIntent,10);
Thread background = new Thread(new Runnable() {
public void run() {
Progresshandler.sendMessage(handler.obtainMessage());//finishes progressDialog
}});
background.start();
but after startactivity it shows a black screen & then displays new activity.
Can I make progressdialog to be shown while the black screen is displayed??
This worked for me:
Intent intent = new Intent(LocationGrid.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
overridePendingTransition(0, 0);
Your code is a bit confusing and unclear. Please specify the goal. Anyway, some things I see:
1- Do not use getApplicationContext(), an Activity is a Context itself, thus it's better to use:
new Intent (this, landingPage.class);
2- You don't need to create a Bundle to add a string to to an intent.
viewIntent.addExtra("ApplicationName", a_Bean.getApplicationName ());
Anyway, passing around your activities the application's name seems like a horrible idea to me. If you really need the application's name throughout the activities, create an Application class as the central point of your application. I really recommend you to revisit your architecture.
3- Are you sure you want to access the activity landingPage from its father? I assume that landingPage is instantiated somewhere. I find this to be a terrible approach. If I am wrong, please provide examples.
As for the rest of the code and your precise question, I can't answer it, I haven't worked with Progress dialogs, but we don't even know what the "bp" variable is and, as I said, you should try to ask again your question clarifying some points.
I resolved above issue by removing DataLoader(i.e. methods that load data from Internet) from called class(i.e. my landingPage.class) to the caller class.