black screen switching between activity
Asked Answered
P

3

5

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??

Pretension answered 13/9, 2010 at 9:3 Comment(5)
Don't display a ProgressDialog in this case, and you won't have the black sliding screen effect.Josie
@Josie I need to display progressDialog as my application downloads data from Internet on the basis of selected "ApplicationName" variable.Pretension
I did removed progressDialog but of no avail.I saw same behavior in other test applications too.Pretension
It's a bad idea to put a progress between launching apps. You need to implement the progress dialog in the one that does the download, but between switching activities. Also if you have a plain interface for downloading data, you should consider using a Service instead of an Activity.Josie
See this: #5219947Aerothermodynamics
P
1

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.

Pretension answered 22/9, 2010 at 9:17 Comment(0)
D
5

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);
Deoxyribonuclease answered 5/5, 2015 at 5:22 Comment(1)
You are always using code snippets for normal code. Code Snippets are only supposed to be used for HTML or javascript or other code which can be run in the browser. You cannot run Java in the browser. Use normal code blocks in the future... I will edit your answer for you this time and fix the formatting etc, but please don't do this anymore in the future. This isn't the first time I told you about this...Pulchia
C
1

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.

Chive answered 13/9, 2010 at 9:24 Comment(1)
Well Maragues 1-I changed 'getApplicationContext()' to 'this' 2-used viewIntent.putExtra("ApplicationName", a_Bean.getApplicationName ()); instead of storing in bundle 3-changed to startActivity & bp is object of a class used for processing and other functions but I am still with no result.Pretension
P
1

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.

Pretension answered 22/9, 2010 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.