0

I'm building an kiosk App for two different versions: Android 6 and before. When app started I have StartActivity and 2 Activities for different APK lvl, start this:

public class StartActivity extends AppCompatActivity {

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

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            startActivity(new Intent(this, MainActivityNew.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        } else {
            startActivity(new Intent(this, MainActivityOld.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }

        finish();
    }
}

MainActivityNew and MainActivityOld must be launchers (when button home is pressed he must call)

In Manifest file i write:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.ng.lockergks">

    <application
        android:name="com.gks.locker.App"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar.FullScreen">

        <activity android:name="ru.gks.locker.ui.activity.StartActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

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

        <activity
            android:name=".MainActivityOld"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait"
            android:stateNotNeeded="true">
            <intent-filter>
                <category android:name="android.intent.category.HOME"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivityNew"
            android:launchMode="singleInstance"
            android:screenOrientation="portrait"
            android:stateNotNeeded="true">
            <intent-filter>
                <category android:name="android.intent.category.HOME"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

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

    </application>

</manifest>

That is, when the application starts, check the version of the API, and depending on it, runs one way or the other activity which should be a launcher. On both versions it does not work. How to define such behavior?

abbath0767
  • 946
  • 2
  • 11
  • 31
  • Is possible to you made a splash screen where you will choose which activity will lunch? https://android.jlelse.eu/right-way-to-create-splash-screen-on-android-e7f1709ba154 – Tomas Ivan Oct 03 '17 at 08:02
  • Or have you tried create layout with different Version qualifier? https://stackoverflow.com/a/6536198/2144352 – Tomas Ivan Oct 03 '17 at 08:03
  • thx for answer. i think about this - but i think maybe possible make this. If i correct understand you - propose to open StartActivity and depending on version of API to open another activity, but only StartActivity have intent filter settings for launcher? – abbath0767 Oct 03 '17 at 08:05
  • @TomasIvan no, not layout. it is different Activity - as in the case of old versions of API implementation kiosk mode will be on me (back button, closing another app and another features) and in the case with new version api (Android 6+) i will try make lockTaskMode, how i read in docs – abbath0767 Oct 03 '17 at 08:08
  • Ohh, I misunderstood you. But you can make a qualifier even for src file. – Tomas Ivan Oct 03 '17 at 08:10
  • And about splash screen. Yes, you will have only one "entry point" to your application, and there you should choose what activity will lunch. Take a look at provided link #Implementation. – Tomas Ivan Oct 03 '17 at 08:12
  • i will try this. And in this moment i read about MultiApk. How you think about this? – abbath0767 Oct 03 '17 at 08:14
  • I never gave it a try. But know its good for reducing size of APK (when you have resources which will be not used in another version), but I'm pretty new to that, so better take a look somewhere else. – Tomas Ivan Oct 03 '17 at 08:19

0 Answers0