Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

In this page you can find the example usage for android.content Intent addFlags.

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:com.oo58.game.texaspoker.AppActivity.java

public void innerRestart() {
    final Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);/* ww w . j  a va  2 s .  co m*/

}

From source file:jahirfiquitiva.iconshowcase.services.MuzeiArtSourceService.java

@Override
public void onCustomCommand(int id) {
    super.onCustomCommand(id);
    if (id == COMMAND_ID_SHARE) {
        Artwork currentArtwork = getCurrentArtwork();
        Intent shareWall = new Intent(Intent.ACTION_SEND);
        shareWall.setType("text/plain");
        String wallName = currentArtwork.getTitle();
        String authorName = currentArtwork.getByline();
        String storeUrl = MARKET_URL + getPackageName();
        String iconPackName = getString(R.string.app_name);
        shareWall.putExtra(Intent.EXTRA_TEXT,
                getString(R.string.share_text, wallName, authorName, iconPackName, storeUrl));
        shareWall = Intent.createChooser(shareWall, getString(R.string.share_title));
        shareWall.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(shareWall);//from   w ww  .ja  v  a 2s  .c o  m
    }
}

From source file:com.dvn.vindecoder.ui.seller.AddVehicalAndPayment.java

@Override
public void onBackPressed() {
    super.onBackPressed();
    Intent intent = new Intent(this, SellerDetail.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);//from w  w w  .  j  av a2 s. c  o m

}

From source file:git.lawpavilionprime.auth._Login.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_);// w  w  w  .  ja v a 2s. com

    mContext = _Login.this;
    txtEmail = (TextView) findViewById(R.id.email);
    txtPassword = (TextView) findViewById(R.id.password);
    btnLogin = (Button) findViewById(R.id.login);
    ckRememberMe = (CheckBox) findViewById(R.id.checkbox);
    txtForgotPassword = (TextView) findViewById(R.id.forgotPassword);
    txtSignUp = (TextView) findViewById(R.id.signUp);
    btnSignUp = (Button) findViewById(R.id.btnSignUp);

    validator = new Validator();
    config = new Config(_Login.this);
    dbAdapter = new UserDBAdapter(this);

    mProgressBar = (LinearLayout) findViewById(R.id.progressMum);
    txtProgressMessage = (TextView) findViewById(R.id.progressMessage);
    btnBkStore = (Button) findViewById(R.id.btnBkStore);
    baseUrl = "http://lawpavilionstore.com/android/login";

    dbAdapter.open(DB_NAME);

    dbAdapter.createUserTable();

    Cursor cursor = dbAdapter.fetch("SELECT * from " + dbAdapter.TABLE_NAME + " limit 1");
    if (cursor != null) {
        //new user
        if (cursor.getCount() == 1) {
            String loggedOut = cursor.getString(cursor.getColumnIndex(dbAdapter.LOG_OUT));
            if (loggedOut.equalsIgnoreCase("0")) {
                //User not looged out..continue
                String token = cursor.getString(cursor.getColumnIndex(dbAdapter.TOKEN));
                Toast.makeText(_Login.this, "Existing", Toast.LENGTH_SHORT).show();

                String set_up_status = cursor.getString(cursor.getColumnIndex(dbAdapter.SET_UP_STATUS));

                if (set_up_status.equalsIgnoreCase("pending")) {

                    Intent intent = new Intent(_Login.this, _Module.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                    //TODO: remove this
                    //dbAdapter.executeQuery("DROP TABLE " + dbAdapter.TABLE_NAME + ";");
                    _Login.this.finish();
                } else {
                    Intent intent = new Intent(_Login.this, Dashboard.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    startActivity(intent);
                    //TODO: remove this
                    //dbAdapter.executeQuery("DROP TABLE " + dbAdapter.TABLE_NAME + ";");
                    _Login.this.finish();
                }
            } else {
                //user has been forced to login..
                //check if gcm exist for user..
                SIGN_IN_TYPE = LOGGED_OUT_USER_TYPE;
            }
        } else {
            //try register GCM for new user
            Log.d("---LOG---", "GCM started");
            new RegisterApp(getApplicationContext()).execute();

            //New user account..
            SIGN_IN_TYPE = NEW_USER_TYPE;
        }
        cursor.close();
    } else {
        Toast.makeText(_Login.this, "DB error", Toast.LENGTH_SHORT).show();
        _Login.this.finish();
        //Do something here
    }
    dbAdapter.close();
    btnLogin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            _email = txtEmail.getText().toString().trim();
            _password = txtPassword.getText().toString().trim();
            boolean isFieldSet = true;

            if (!validator.isValidEmail(_email)) {
                txtEmail.setError(Validator.emailErrorMessage);
                isFieldSet = false;
            }

            if (validator.isEmpty(_password)) {
                txtPassword.setError(Validator.defaultErrorMessage);
                isFieldSet = false;
            }
            //Toast.makeText(_Login.this, "Ready for Async Task", Toast.LENGTH_SHORT).show();

            if (isFieldSet) {
                connectIfInternetIsAvailable();
            } else {
                return;
            }
        }
    });
    txtForgotPassword.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(_Login.this, _ForgotPassword.class);
            startActivity(intent);
        }
    });

    btnSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(_Login.this, _SignUp.class);
            startActivity(intent);
        }
    });

    //        txtSignUp.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //
    //                Intent intent = new Intent(_Login.this, _SignUp.class);
    //                startActivity(intent);
    //            }
    //        });
    btnBkStore.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            Intent intent = new Intent(_Login.this, BookStore.class);
            startActivity(intent);
        }
    });
    mProgressBar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //no action
        }
    });
}

From source file:com.ichi2.anki.DeckOptions.java

private void restartActivity() {
    if (Build.VERSION.SDK_INT >= 11) {
        recreate();//from   w  w w  . j  a v  a 2s . c  om
    } else {
        Intent intent = getIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        finish();
        overridePendingTransition(0, 0);
        startActivity(intent);
        overridePendingTransition(0, 0);
    }
}

From source file:com.shafiq.mytwittle.App.java

public void restartApp(Activity currentActivity) {
    Intent intent = getBaseContext().getPackageManager()
            .getLaunchIntentForPackage(getBaseContext().getPackageName());
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION
            | Intent.FLAG_ACTIVITY_CLEAR_TASK);
    currentActivity.overridePendingTransition(0, 0);
    currentActivity.startActivity(intent);
}

From source file:com.nnm.smsviet.Message.java

/**
 * Fetch MMS parts./*from w  w  w.j  a v  a2 s .  com*/
 * 
 * @param context
 *            {@link Context}
 */
private void fetchMmsParts(final Context context) {
    final ContentResolver cr = context.getContentResolver();
    Cursor cursor = cr.query(URI_PARTS, null, PROJECTION_PARTS[INDEX_MID] + " = ?",
            new String[] { String.valueOf(this.id) }, null);
    if (cursor == null || !cursor.moveToFirst()) {
        return;
    }
    final int iID = cursor.getColumnIndex(PROJECTION_PARTS[INDEX_ID]);
    final int iCT = cursor.getColumnIndex(PROJECTION_PARTS[INDEX_CT]);
    final int iText = cursor.getColumnIndex("text");
    do {
        final int pid = cursor.getInt(iID);
        final String ct = cursor.getString(iCT);
        Log.d(TAG, "part: " + pid + " " + ct);

        // get part
        InputStream is = null;

        final Uri uri = ContentUris.withAppendedId(URI_PARTS, pid);
        try {
            is = cr.openInputStream(uri);
        } catch (IOException e) {
            Log.e(TAG, "Failed to load part data", e);
        }
        if (is == null) {
            Log.i(TAG, "InputStream for part " + pid + " is null");
            if (iText >= 0 && ct.startsWith("text/")) {
                this.body = cursor.getString(iText);
            }
            continue;
        }
        if (ct == null) {
            continue;
        }
        if (ct.startsWith("image/")) {
            this.picture = BitmapFactory.decodeStream(is);
            final Intent i = new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(uri, ct);
            i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            this.contentIntent = i;
            continue; // skip the rest
        } else if (ct.startsWith("video/") || ct.startsWith("audio/")) {
            this.picture = BITMAP_PLAY;
            final Intent i = new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(uri, ct);
            this.contentIntent = i;
            continue; // skip the rest
        } else if (ct.startsWith("text/")) {
            this.body = this.fetchPart(is);
        }

        if (is != null) {
            try {
                is.close();
            } catch (IOException e) {
                Log.e(TAG, "Failed to close stream", e);
            } // Ignore
        }
    } while (cursor.moveToNext());
}

From source file:com.fabernovel.alertevoirie.MyIncidentsActivity.java

/** Called when the activity is first created. */
@Override/*from   w w w  . j a  v a 2  s  .  c  o  m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.layout_report_lists);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon_mes_rapports);
    tabs = (RadioGroup) findViewById(R.id.RadioGroup_tabs);
    tbmap = (ToggleButton) findViewById(R.id.ToggleButton01);
    tbmap.setChecked(false);
    tbmap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                tbmap.setChecked(false);
                Intent i = new Intent(MyIncidentsActivity.this, MyIncidentsActivityMap.class);
                i.putExtra("tab1", title[0]);
                i.putExtra("tab2", title[1]);
                i.putExtra("tab3", title[2]);
                i.putExtra("datas", data.toString());
                i.putExtra("tab", checked);
                i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);// .addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(i);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
            }

        }
    });

    if (getIntent().getExtras() != null) {

        title[0] = getIntent().getExtras().getString("tab1");
        title[1] = getIntent().getExtras().getString("tab2");
        title[2] = getIntent().getExtras().getString("tab3");
        ((TextView) tabs.getChildAt(0)).setText(title[0]);
        if (title[0].startsWith("0"))
            ((TextView) tabs.getChildAt(0)).setEnabled(false);
        ((TextView) tabs.getChildAt(1)).setText(title[1]);
        if (title[1].startsWith("0"))
            ((TextView) tabs.getChildAt(1)).setEnabled(false);
        ((TextView) tabs.getChildAt(2)).setText(title[2]);
        if (title[2].startsWith("0"))
            ((TextView) tabs.getChildAt(2)).setEnabled(false);

        checked = getIntent().getExtras().getInt("tab");

        try {
            data = new JSONObject(getIntent().getExtras().getString("datas"));
        } catch (JSONException e) {
            Log.e(Constants.PROJECT_TAG, "JSon data exception", e);
        }

        setAdapterForTab(gettabIndex(tabs.getCheckedRadioButtonId()));

    } else {
        // sendRequest();
    }

    // get view references

    tabs.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            Log.d(Constants.PROJECT_TAG, "checked : " + checkedId);
            checked = checkedId;
            setAdapterForTab(gettabIndex(checkedId));
        }
    });

    tabs.check(getId());
}

From source file:de.elanev.studip.android.app.backend.net.oauth.SignInFragment.java

/**
 * Starts the next activity after prefetching.
 *///from   w  w  w.jav  a  2  s .c o  m
public void startMainActivity() {
    Intent intent = new Intent(getActivity(), MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);

    Log.i(TAG, "Starting news Activity...");
    if (!ApiUtils.isOverApi11()) {
        getActivity().finish();
    }
}

From source file:com.zigvine.zagriculture.UIActivity.java

@Override
public void startActivityForResult(Intent intent, int requestCode) {
    ActivityInfo info = intent.resolveActivityInfo(getPackageManager(), 0);
    if (info != null && info.packageName != null && info.packageName.equals(getPackageName())) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    }/*from   w  ww . j a  v a2  s  . c om*/
    super.startActivityForResult(intent, requestCode);
}