Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17111

Splash Screen for slow loading Android App

$
0
0

@nov wrote:

I try to add Splash Screen to my Cocos2dx Android app, which I ported from iOS.

Because:
1. It takes so much time, before the App starts (around 17 seconds).
2. It shows black screen during waiting.

I tried to add Splash Sreen Java way, but it displays image for a few seconds only and then switches back again to black screen for the rest of start up time.

I have this code there.

styles.xml

<resources>

<!-- Base application theme. -->
<!-- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> -->
<!-- Customize your theme here. -->
<!-- </style> -->

    <style name="SplashTheme" parent="android:style/Theme"> <!-- Theme.AppCompat.NoActionBar @android:style/Theme.NoTitleBar.Fullscreen -->
        <item name="android:windowBackground">@drawable/background_splash</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowFullscreen">true</item>
        <item name="android:windowContentOverlay">@null</item>
    </style>

</resources>

SplashActivity.Java

package com.bignerdranch.android.splash;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class SplashActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = new Intent(this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}

drawable/background_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item
        android:drawable="@color/gray"/>

    <item>
        <bitmap
            android:gravity="center"
            android:src="@mipmap/ic_launcher"/>
    </item>

</layer-list>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.de.test"
    android:installLocation="auto">

    <uses-feature android:glEsVersion="0x00020000" />
    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:icon="@drawable/icon">

        <!-- Tell Cocos2dxActivity the name of our .so -->
		<meta-data android:name="android.app.lib_name"
				   android:value="cocos2dcpp" />

        <!-- android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  portrait -->
        <activity
            android:name="org.cocos2dx.cpp.AppActivity"
            android:launchMode="singleTop"
            android:screenOrientation="sensorPortrait"
            android:configChanges="orientation|keyboardHidden|screenSize"
            android:label="@string/app_name"
            android:theme="@style/SplashTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

</manifest>
  1. How to improve it, to show Splash Screen during whole Cocos2dx App loading (instead of black screen)?

  2. How to improve start up time?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>