android – Navigating to parent activity


I have two flavors one is free and another one is paid

I have the code only in main—> Java folder trying to figure the code which is free and paid and leaving free and paid folders empty.

Now I have MainActivity which launches from that user navigates to Activity A, Activity B…

When User goes to Activity A and perform some operations he would like to navigate to parent activity ie…MainActivity he clicks on up navigation.

Here comes the problem

When he clicks up navigation how do I come to know he has to go to parent activity using flavor

I have set up my gradle file as shown below:

 productFlavors {
    free {
        applicationId "com.abc.xyz.free"
        versionName "${versionMajor}.${versionMinor}.${versionBuild}"
        buildConfigField "boolean", "PAID_VERSION", "false"
        resValue "string", "android:value", applicationId
        dimension "version"
    }

    full{
        applicationId "com.abc.xyz.full"
        versionName "${versionMajor}.${versionMinor}.${versionBuild}"
        buildConfigField "boolean", "PAID_VERSION", "true"
        dimension "version"
    }
}

I’m unable to figure how does I change the android value in manifest file :

  <activity
        android:name=".ActivityA"
        android:label="ActivityA"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden"
        android:launchMode="singleTop">
        <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity"></meta-data>
    </activity>
    <activity
        android:name=".ActivityB"
        android:label="ActivityB"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="stateHidden">
        <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".MainActivity"></meta-data>
    </activity>



لینک منبع

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *