Tammam
Tammam

Reputation: 438

intent setFlags error

What's wrong, really marked red?

here is my Intent

public void onBackPressed() {
    super.onBackPressed();
    Intent i = new Intent(this, MainActivity.class);
    i.setFlags(268468224);
    startActivity(i);
    finish();
    finishAffinity();
    System.exit(0);
 }}

i.setFlags(268468224) marker red, any solution?

Upvotes: 1

Views: 2767

Answers (2)

CodeToLife
CodeToLife

Reputation: 4171

Only this couple gives us that result :

Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK

for 0x10008000(i.e.268468224)

Upvotes: 2

Pankaj Kant Patel
Pankaj Kant Patel

Reputation: 2060

Android Intent setFlags() has @Retention(RetentionPolicy.SOURCE) annotation.That's why your line i.setFlags(268468224); marked as red because violation of it's rules.

  /**
     * Set special flags controlling how this intent is handled.  Most values
     * here depend on the type of component being executed by the Intent,
     * specifically the FLAG_ACTIVITY_* flags are all for use with
     * {@link Context#startActivity Context.startActivity()} and the
     * FLAG_RECEIVER_* flags are all for use with
     * {@link Context#sendBroadcast(Intent) Context.sendBroadcast()}.
     *
     * <p>See the
     * <a href="{@docRoot}guide/topics/fundamentals/tasks-and-back-stack.html">Tasks and Back
     * Stack</a> documentation for important information on how some of these options impact
     * the behavior of your application.
     *
     * @param flags The desired flags.
     * @return Returns the same Intent object, for chaining multiple calls
     * into a single statement.
     * @see #getFlags
     * @see #addFlags
     * @see #removeFlags
     */
    public @NonNull Intent setFlags(@Flags int flags) {
        mFlags = flags;
        return this;
    }

 @Retention(RetentionPolicy.SOURCE)
    public @interface Flags {}

    /** @hide */
    @IntDef(flag = true, prefix = { "FLAG_" }, value = {
            FLAG_FROM_BACKGROUND,
            FLAG_DEBUG_LOG_RESOLUTION,
            FLAG_EXCLUDE_STOPPED_PACKAGES,
            FLAG_INCLUDE_STOPPED_PACKAGES,
            FLAG_DEBUG_TRIAGED_MISSING,
            FLAG_IGNORE_EPHEMERAL,
            FLAG_ACTIVITY_NO_HISTORY,
            FLAG_ACTIVITY_SINGLE_TOP,
            FLAG_ACTIVITY_NEW_TASK,
            FLAG_ACTIVITY_MULTIPLE_TASK,
            FLAG_ACTIVITY_CLEAR_TOP,
            FLAG_ACTIVITY_FORWARD_RESULT,
            FLAG_ACTIVITY_PREVIOUS_IS_TOP,
            FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS,
            FLAG_ACTIVITY_BROUGHT_TO_FRONT,
            FLAG_ACTIVITY_RESET_TASK_IF_NEEDED,
            FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY,
            FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
            FLAG_ACTIVITY_NEW_DOCUMENT,
            FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET,
            FLAG_ACTIVITY_NO_USER_ACTION,
            FLAG_ACTIVITY_REORDER_TO_FRONT,
            FLAG_ACTIVITY_NO_ANIMATION,
            FLAG_ACTIVITY_CLEAR_TASK,
            FLAG_ACTIVITY_TASK_ON_HOME,
            FLAG_ACTIVITY_RETAIN_IN_RECENTS,
            FLAG_ACTIVITY_LAUNCH_ADJACENT,
            FLAG_RECEIVER_REGISTERED_ONLY,
            FLAG_RECEIVER_REPLACE_PENDING,
            FLAG_RECEIVER_FOREGROUND,
            FLAG_RECEIVER_NO_ABORT,
            FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT,
            FLAG_RECEIVER_BOOT_UPGRADE,
            FLAG_RECEIVER_INCLUDE_BACKGROUND,
            FLAG_RECEIVER_EXCLUDE_BACKGROUND,
            FLAG_RECEIVER_FROM_SHELL,
            FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS,
    })

Upvotes: 0

Related Questions