I tried using this flag in setFlags from the tutorial, but its deprecated, what am I doing

FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESETDeprecated so what should i use?

private Intent createShareForecastIntent() {

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mforecastStr + FORECAST_SHARE_HASHTAG);
    return shareIntent;


}
+1
source share
2 answers

Documentation citation :

According to API 21, this is identical to the FLAG_ACTIVITY_NEW_DOCUMENT, which should be used instead.

Since both characters have the same numerical value ( 0x00080000), it doesn't really matter which one you are using regarding runtime behavior. If yours compileSdkVersionis 21 or higher, switch toFLAG_ACTIVITY_NEW_DOCUMENT

+4
source

(Intent)

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
        }
0

All Articles