-1
我的启动画面出现在genymotion中,但在真实的Android设备上,屏幕仅显示白色5秒。Android启动画面不可见
的布局是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/launchphone"
android:scaleType="fitXY"/>
</RelativeLayout>
该活动的代码:
public class MainActivity extends Activity {
private DownloadAPITask task;
private String response;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(getResources().getConfiguration().isLayoutSizeAtLeast(Configuration.SCREENLAYOUT_SIZE_LARGE)){
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}else{
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
setContentView(R.layout.activity_main);
task = new DownloadAPITask(this, null, new Runnable(){
@Override
public void run(){
onAPIDownload();
}
});
task.execute(new APIRequest("http://my-site.com/api/", "request=asd"));
}
private void onAPIDownload(){
StringBuilder strb = task.getResponse();
if(strb == null){
response = null;
}else{
response = strb.toString();
}
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
launch();
}
}, 2000);
}
private void launch(){
Intent intent = new Intent(this, StartActivity.class);
intent.putExtra(StartActivity.API, response);
startActivity(intent);
finish();
}
}
抽拉/ launchphone是位于在res .png文件/抽拉/未在任何的dpi的依赖性可绘制的位置,因为它只是全屏缩放。我假设从真实设备上的漫长启动时间开始,它就是闪屏,而不是呈现这个图像,而只是显示为白色。
任何帮助将不胜感激。
确保您启动了Splash Activity,等待,终止它,并最终启动主要活动 –
您是否收到响应? – JUL2791