Android启动屏和引导页
启动app的时候闪黑屏?
可以用自己app的logo来代替黑屏,且看如下配置:
1 | <!-- res/drawable/welcome_bg --> |
1 | <!-- add below code to your style.xml --> |
预加载主内容
为了在展示欢迎页的时候提前加载,我们调换下MainActivity和WelcomeActivity顺序
1 | <!-- add below code to your AndroidMainfest.xml --> |
1 |
|
可以参考: https://github.com/lyloou/lou/blob/demo/test/src/main/AndroidManifest.xml
启动已经存在的activity
栈
- android - Resume the Activity instead of Starting if already exists in back stack - Stack Overflow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22You can add this two lines and try:
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Write this in your manifest file inside Activity
<activity
android:name=".SettingsActivity"
android:launchMode="singleInstance"
android:screenOrientation="portrait" >
</activity>
"singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack. Moreover, the device can hold only one instance of the activity at a time — only one such task.
You can use SingleTask or SingleInstance
"singleTask" - The system creates the activity at the root of a new task and routes the intent to it. However, if an instance of the activity already exists, the system routes the intent to existing instance through a call to its onNewIntent() method, rather than creating a new one.
"singleInstance" - Same as "singleTask", except that the system doesn't launch any other activities into the task holding the instance. The activity is always the single and only member of its task.
Refer this link http://developer.android.com/guide/topics/manifest/activity-element.html
可以参考: https://github.com/lyloou/lou/blob/demo/test/src/main/java/com/lyloou/test/WelcomeActivity.java