A
A
AndreyFr2015-03-02 15:53:17
Java
AndreyFr, 2015-03-02 15:53:17

Strange behavior of NavUtils.navigateUpFromSameTask?

Strange behavior of NavUtils.navigateUpFromSameTask.
If the manifest says

<activity
            android:name=".SubActivity"
            android:label="@string/title_activity_sub" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".MainActivity" />
        </activity>

then after navigating with SubActivity a crash occurs:
java.lang.IllegalArgumentException: Activity SubActivity does not have a parent activity name specified. (Did you forget to add the android.support.PARENT_ACTIVITY <meta-data>  element in your manifest?)
            at android.support.v4.app.NavUtils.navigateUpFromSameTask(NavUtils.java:178)
...........

But when you write android:value="org.domen.app.MainActivity"
there is no crash ...
Although there should not be a crash in the first case either. Where to dig?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Lebedev, 2015-03-06
@kamiLLxiii

Maybe it depends on the OS version. Try adding the same parameter to the activity tag

<activity
        android:name=".SubActivity"
        android:label="@string/title_activity_sub"
        android:parentActivityName=".MainActivity">

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

Taken from here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question