I'm working on my first Android app and I don't know how to sort one issue in right way. I checked similar SO topic, for example that one but it doesn't fully explain how to set up manifest file.
I have HomeActivity, BrandActivity, MainCategoryActivity and ProductDetailsActivity it works that if you are in home one you can go to brand and from brand to main and so on. There is back button in every activity (except from home) and by clicking it it takes you to the previous one, from product to main, main to brand and brand to home.
My manifest file looks like that:
<activity
android:name="com.test.HomeActivity"
android:label="@string/activity_home"
android:launchMode="singleTask"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.test.BrandsActivity"
android:label="@string/activity_brands"
android:launchMode="singleTop"
android:parentActivityName="com.test.HomeActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".HomeActivity" />
</activity>
<activity
android:name="com.test.MainCategoryActivity"
android:label="@string/activity_main_category"
android:launchMode="singleTop"
android:parentActivityName="com.test.BrandsActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".BrandsActivity" />
</activity>
<activity
android:name="com.test.ProductDetailActivity"
android:label="@string/activity_product_list"
android:launchMode="singleTop"
android:parentActivityName="com.test.MainCategoryActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainCategoryActivity" />
</activity>
Now in home, brand and main activities there is search option which takes you to ProductDetailActivity.
My question is how to make the intent from each of those activity to ProductDetailsActivity that when you press the back button in ProductDetailsActivity you go back to the previous one, so for example if you open product activity from brand you should go back from product to brand after back button is pressed, bu if you opened it from home it takes you back to home, and so on? Do I need to make some changes in manifest file and how to create intent to open ProductDetailsActivity.
And the last question what if I want to open ProductDetailsActivity from ProductDetailsActivity, How can I do it? How to make sure that back button takes me from ProductDetailsActivity to ProductDetailsActivity if it was open via ProductDetailsActivity or lets say BrandActivity if it was open view brands?
Thanks in advance.