When I am trying to start second activity from the first one, but it shows me black screen before showing new activity layout. Here is my code:
Intent intent = new Intent(MessagesActivity.this, MessageTextActivity.class);
intent.putExtra("Sender", items.get(position).subject);
intent.putExtra("Date", items.get(position).date);
intent.putExtra("Text", items.get(position).text);
intent.putExtra("Position", position);
startActivity(intent);
On Android other than KitKat when I add in manifest under application android:theme="@android:style/Theme.Translucent.NoTitleBar"
, I don't see black splash when starting other activity. Which is great, but if I remove android:theme
the black splash is back.
In the other hand, on KitKat, when I remove
android:theme="@android:style/Theme.Translucent.NoTitleBar"
from manifest, it works good.
But, if I keep android:theme="@android:style/Theme.Translucent.NoTitleBar"
I also don't see black splash screen when opening other activity, but I have other problem. The problem is if user clicks that View
which starts new activity a lot of times, than if there is some icon on desktop in that place, that application gets started! It seems that my activity(the one where I click View
to open other) disappeared, and user clicked on icon on desktop (home screen).
Putting android:theme="@android:style/Theme.Translucent.NoTitleBar"
in manifest helps me in all versions of Android except in KitKat.
Edit: 15/8/2014
This View
I am clicking on is a ListView
item. When I click on View
the first time I don't see black screen flash. But if I exit the activity I just entered(click on Back), and if I wait for 1-2 seconds and I click on the View
I don't see black flash again. But If I click before 1-2 seconds, then the black screen flash appears.
In the first activity, in onResume
method, I don't have anything. And in second activity, in onCreate
method, I have this code:
ThemeManager.loadTheme(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_full_message);
initTextViews();
initActionBar();
In ThemeManager.loadTheme(this)
I set the style in my activity (because user can change themes in the app), and that styles are defined like this:
<style name="Theme.MyTheme.Blue" parent="@style/Theme.Sherlock.Light">
and <style name="Theme.MyTheme.Green" parent="@style/Theme.Sherlock.Light">
I use Sherlock Styles.
Solution :)
I found what was causing this black screen. I added animation when closing the second activity, and showing the first one. The entering duration of animation was longer than duration of exiting activity. The entering animation was still in progress, and then I click View which opens new activity with black screen flash! Anyway, many thanks on suggestions.
I faced a similar problem, and solved by adding theme to second activity in
AndroidManifest.xml
: