заставка не появляется в Android после попытки многих решений - PullRequest
0 голосов
/ 31 января 2019

Я очень новичок в Android и пытаюсь реализовать заставку, следуя инструкции с веб-сайта.

Я сделал все, что там было написано, но когда я запускаю свое приложение, заставка делаетне появляются

Я взял ссылку на многие вопросы о StackOverflow, но, похоже, это не работает

Экран-заставка не появляется

Ниже мой файл "activity_splash", расположенный по адресу "res-> layout-> activity_splash.xml"

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/googleg_standard_color_18" >

<ImageView
    android:id="@+id/imgLogo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:src="@drawable/image_offline" />

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="10dp"
    android:textSize="12dp"
    android:textColor="#454545"
    android:gravity="center_horizontal"
    android:layout_alignParentBottom="true"
    android:text="www.androidhive.info" />

Ниже мой "SplashScreenФайл .java "находится рядом с файлом MainActivity.java

// Splash screen timer
private static int SPLASH_TIME_OUT = 3000;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);

    new Handler().postDelayed(new Runnable() {

        /*
         * Showing splash screen with a timer. This will be useful when you
         * want to show case your app logo / company
         */

        @Override
        public void run() {
            // This method will be executed once the timer is over
            // Start your app main activity
            Intent i = new Intent(SplashScreen.this, MainActivity.class);
            startActivity(i);

            // close this activity
            finish();
        }
    }, SPLASH_TIME_OUT);
}

*

* Ниже приведен мой файл" AndroidManifest.xml "**

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.webkit.PermissionRequest" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:name="android.gold.webview.codecanyon.com.bakairy.WebViewApp"
    android:theme="@style/AppTheme">
    <activity
        android:name="android.gold.webview.codecanyon.com.bakairy.MainActivity"
        android:configChanges="orientation|screenSize">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

        <intent-filter android:label="@string/deeplinking">
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <!-- Accepts URIs that begin with "https://bakairy.boehub.com/link=” -->
            <data android:scheme="http"
                android:host="https://bakairy.boehub.com"
                android:pathPrefix="/link="
                />

        </intent-filter>


    </activity>
    <activity android:name=".SplashScreen" />

    <meta-data android:name="com.onesignal.NotificationOpened.DEFAULT" android:value="DISABLE" />
</application>

Ответы [ 3 ]

0 голосов
/ 31 января 2019

братан, чтобы сначала начать работу, сначала нужно запустить ее, я изменяю ваш код, используйте его вместо этого.замените код манифеста для всплеска активности.и удалите фильтр намерений из основного действия

  <activity android:name=".SplashScreen" >

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

0 голосов
/ 31 января 2019

Вам нужно установить фильтр намерений только на заставке .. вот так ..

<activity android:name=".SplashScreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

MainActivity не нужен фильтр намерений, вы должны его удалить.

0 голосов
/ 31 января 2019

Ваш заставки не появляется, потому что у вас MainActivity в качестве активности запуска в manifest

Измените manifest код:

<activity android:name=".SplashScreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<activity android:name=".MainActivity" />
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...