我尝试在教程中的 setFlags 中使用这个标志,但它已被弃用,我该怎么办
I tried using this Flag in setFlags from tutorial but its deprecated, what do i do
FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
已弃用;那我应该用什么?
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;
}
As of API 21 this performs identically to FLAG_ACTIVITY_NEW_DOCUMENT which should be used instead of this.
由于两个符号具有相同的数值 (0x00080000
),因此就运行时行为而言,使用哪个并不重要。如果您的 compileSdkVersion
为 21 或更高,请切换到 FLAG_ACTIVITY_NEW_DOCUMENT
看这里(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);
}
FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
已弃用;那我应该用什么?
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;
}
As of API 21 this performs identically to FLAG_ACTIVITY_NEW_DOCUMENT which should be used instead of this.
由于两个符号具有相同的数值 (0x00080000
),因此就运行时行为而言,使用哪个并不重要。如果您的 compileSdkVersion
为 21 或更高,请切换到 FLAG_ACTIVITY_NEW_DOCUMENT
看这里(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);
}