I tried using this Flag in setFlags from tutorial but its deprecated, what do i do
Asked Answered
P

2

3

FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET is deprecated; 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;


}
Pipsissewa answered 16/10, 2015 at 20:28 Comment(1)
Consider using ShareCompat.IntentBuilder, which does much of this for you.Discredit
Z
10

Quoting the documentation:

As of API 21 this performs identically to FLAG_ACTIVITY_NEW_DOCUMENT which should be used instead of this.

Since both symbols have the same numerical value (0x00080000), it does not really matter which one you use in terms of runtime behavior. If your compileSdkVersion is 21 or higher, switch to FLAG_ACTIVITY_NEW_DOCUMENT

Zemstvo answered 16/10, 2015 at 20:30 Comment(0)
I
2

See here (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);
        }
Indicant answered 16/12, 2017 at 14:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.