我正在为Android开发应用程序。 该应用使用Google Play服务,需要一些许可。
启动器活动非常简单,只是设置内容视图。 我在各种设备上对其进行了测试,结果如下:
HOMTOM HT3 PRO,Android 5.1 快速展示第一项活动。
HUAWEI P8 Lite,Android 6.0 有时会在启动前显示黑屏5-10秒
Galaxy A3,Android 6.1 它被卡在黑屏上。
Nexus 5 被困在黑屏上。
以下是Galaxy A3的一些日志:
12-01 15:38:02.911 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:02.931 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59261438
12-01 15:38:03.291 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:03.331 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:03.331 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{ab1c097 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:03.381 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59261887
12-01 15:38:03.731 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:03.761 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59262266
12-01 15:38:04.121 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:04.171 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:04.171 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{4f91b9e I.ED..... R.....I. 0,0-0,0}
12-01 15:38:04.221 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59262722
12-01 15:38:04.581 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:04.601 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59263105
12-01 15:38:04.961 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:05.001 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:05.001 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{1cf681 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:05.051 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59263551
12-01 15:38:05.391 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:05.421 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59263921
12-01 15:38:05.761 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:05.811 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:05.811 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{7010fb0 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:05.851 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59264352
12-01 15:38:06.181 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:06.211 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59264717
12-01 15:38:06.601 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:06.651 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:06.651 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{830db5b I.ED..... R.....I. 0,0-0,0}
12-01 15:38:06.691 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59265199
12-01 15:38:07.031 16359-16359/com.package.appname D/ViewRootImpl: MSG_RESIZED_REPORT: ci=Rect(0, 36 - 0, 0) vi=Rect(0, 36 - 0, 0) or=1
12-01 15:38:07.061 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59265564
12-01 15:38:07.431 16359-16359/com.package.appname D/ViewRootImpl: #3 mView = null
12-01 15:38:07.491 16359-16359/com.package.appname D/SecWifiDisplayUtil: Metadata value : none
12-01 15:38:07.491 16359-16359/com.package.appname D/ViewRootImpl: #1 mView = com.android.internal.policy.PhoneWindow$DecorView{7184a72 I.ED..... R.....I. 0,0-0,0}
12-01 15:38:07.531 16359-16359/com.package.appname I/Timeline: Timeline: Activity_launch_request id:com.package.appname time:59266036
我的开始活动
public class StartActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
//more code
}
}
但是在调试时我清楚地看到等待时间是在onCreate调用之前。可能它取决于应用程序组成的大量文件?我有73个java类+ ~100 drawable。
仅供参考,这是我的gradle文件。
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 24
buildToolsVersion '24.0.1'
defaultConfig {
applicationId "com.package.appname"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
manifestPlaceholders = [onesignal_app_id: "****",
onesignal_google_project_number: "*****"]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:percent:24.2.0'
compile 'com.bignerdranch.android:recyclerview-multiselect:+'
compile 'com.google.android.gms:play-services-maps:9.6.0'
compile 'com.google.android.gms:play-services-location:9.6.0'
compile 'com.google.android.gms:play-services-auth:9.6.0'
compile 'com.google.android.gms:play-services-gcm:9.6.0'
compile 'com.google.firebase:firebase-messaging:9.6.0'
compile 'com.google.firebase:firebase-database:9.6.0'
compile 'com.google.firebase:firebase-storage:9.6.0'
compile 'com.google.firebase:firebase-auth:9.6.0'
compile 'com.google.firebase:firebase-crash:9.6.0'
compile 'com.firebaseui:firebase-ui:0.6.0'
compile 'com.firebaseui:firebase-ui-database:0.6.0'
compile 'com.firebaseui:firebase-ui-auth:0.6.0'
compile 'com.firebaseui:firebase-ui-storage:0.6.0'
compile 'com.firebase:geofire-android:2.1.0'
compile 'com.jakewharton:butterknife:8.2.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.machinarius:preferencefragment:0.1.1'
compile 'commons-io:commons-io:2.4'
compile 'com.soundcloud.android:android-crop:1.0.1@aar'
compile 'br.com.instachat:emoji-library:1.0.8'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'org.apmem.tools:layouts:1.10@aar'
compile 'com.github.chrisbanes:PhotoView:1.3.1'
compile 'com.dinuscxj:circleprogressbar:1.1.1'
testCompile 'junit:junit:4.12'
apt 'com.jakewharton:butterknife-compiler:8.2.1'
}
apply plugin: 'com.google.gms.google-services'
我的开始布局
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#ffffff"
android:gravity="center_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/start_logo"
>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.2"
></View>
<ImageView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.6"
android:adjustViewBounds="true"
app:srcCompat="@drawable/logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0.2"
></View>
</LinearLayout>
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminate="true"
android:layout_below="@+id/start_logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:id="@+id/start_progress"/>
<TextView
android:text="Loading..."
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/start_progress"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:id="@+id/start_processing"
android:textColor="#000000"/>
</RelativeLayout>