Как показать заставку при запуске приложения из ярлыка - PullRequest
0 голосов
/ 20 февраля 2019

Мне не удалось узнать, как отобразить заставку при запуске приложения из ярлыка.Ярлык - это прямой путь к открытию определенной активности, поэтому заставка игнорируется.Любая идея, как включить заставку на каждой комбинации запуска приложения?

Моя реализация заставки:

public class SplashScreen extends AppCompatActivity {

    Context context = this;

    /** Duration of wait **/
    private final int SPLASH_DISPLAY_LENGTH = 2000;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed( new Runnable(){
            @Override
            public void run() {
                /* Create an Intent that will start the Menu-Activity. */
                Intent goToMainActivity = new Intent(SplashScreen.this, MainActivity.class);
                goToMainActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
                startActivity(goToMainActivity);
                finish();
            }
        }, SPLASH_DISPLAY_LENGTH);
    }

}

Манифест:

<activity
            android:name=".SplashScreen"
            android:label="@string/app_name"
            android:noHistory="true"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <meta-data android:name="android.app.shortcuts" android:resource="@xml/shortcut" />
        </activity>
        <activity
            android:name=".MainActivity"
            android:noHistory="true">
        </activity>

Ярлык:

<shortcut
        android:shortcutId="shortCutEnvironment"
        android:enabled="true"
        android:icon="@drawable/ic_action_temperature"
        android:shortcutShortLabel="@string/shortcut_environment"
        android:shortcutLongLabel="@string/shortcut_environment">

        <intent
            android:action="android.intent.action.VIEW"
            android:targetPackage="com.app.myapp"
            android:targetClass="com.app.myapp.EnvironmnetScreen"
            />
        <category android:name="android.shortcut.conversation"/>

    </shortcut>
...