Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot find symbol variable FLAG_ACTIVITY_CLEAR_TASK

Tags:

android

After updating support version to 27.0.0 compiler giving error

cannot find symbol variable FLAG_ACTIVITY_CLEAR_TASK.

Is this variable removed? What use instead?

code example:

 Intent intent = new Intent(SetNewPasswordActivity.this, SignInActivity.class);
 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
like image 800
Axbor Axrorov Avatar asked Nov 02 '17 08:11

Axbor Axrorov


3 Answers

cannot find symbol variable FLAG_ACTIVITY_CLEAR_TASK

You should use Intent.FLAG_ACTIVITY_CLEAR_TASK.

If set in an Intent passed to Context.startActivity(), this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started.

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
like image 86
IntelliJ Amiya Avatar answered Oct 01 '22 23:10

IntelliJ Amiya


IntentCompat.FLAG_ACTIVITY_CLEAR_TASK is deprecated thus please use Intent.FLAG_ACTIVITY_CLEAR_TASK directly.

This flag can only be used in conjunction with #FLAG_ACTIVITY_NEW_TASK.

like image 45
dbog Avatar answered Oct 01 '22 22:10

dbog


use this

 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);

instead of this

 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | IntentCompat.FLAG_ACTIVITY_CLEAR_TASK);
like image 36
AskNilesh Avatar answered Oct 01 '22 21:10

AskNilesh