Search code examples
androidactivity-stack

taskstackbuilder for api 14


My compiler show this message...

Call required API level 16 (current min is 14)

The question is.. "Is this code is okay to run in api 14 or not??" because I have no device to test this API version since AVD doesn't have GPS (Requirement) Do I have to implement support library or not??

NOTE

It works perfectly on API 16 and above

TaskStackBuilder

    PendingIntent contentIntent = TaskStackBuilder.create(this)
            // add all of DetailsActivity's parents to the stack,
            // followed by DetailsActivity itself
            .addParentStack(Activity_TrackingMode.class)
            .addNextIntent(new Intent(this, Activity_TrackingMode.class))
            .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

AndroidManifest

    <activity android:name=".Activity_TrackingMode"
              android:label="@string/app_name"
              android:screenOrientation="portrait"
              android:parentActivityName=".Activity_Screen1">
        <!-- Parent activity meta-data to support 4.0 and lower -->
        <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".Activity_Screen1" />
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT"/>
        </intent-filter>
    </activity>

Solution

  • You have to use android.support.v4.app.TaskStackBuider

    http://developer.android.com/reference/android/support/v4/app/TaskStackBuilder.html

    to run on API 14