Speed Demon
Speed Demon

Reputation: 691

Android parent activity

I have this in my manifest:

<activity
android:name=".PimMediaActivity"
android:hardwareAccelerated="true"
android:screenOrientation="portrait">

       <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".SettingsActivity" />

</activity> 

On my PimMediaActivity which has SettingsActivity declared as its parent in the manifest, I have a custom back button. There are cases like from push notification where I need to start the PimMediaActivity directly, but I want to be able to go back to the parent activity when the button is clicked. Is this feature only working with the ActionBar back button ?!

Upvotes: 0

Views: 622

Answers (2)

Alejandro Cumpa
Alejandro Cumpa

Reputation: 2363

You should put this :

<activity
    android:name=".PimMediaActivity"
    android:hardwareAccelerated="true"
    android:screenOrientation="portrait"
   android:parentActivityName=".activities.SettingsActivity" >

            <!-- Parent activity meta-data to support 4.0 and lower -->
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".SettingsActivity" />
        </activity>

Upvotes: 2

dominik4142
dominik4142

Reputation: 576

Are you interested in retrieving the app state from before opening notification?

If no, you can just call startActivity(Intent) in onClick() method..

Upvotes: 0

Related Questions