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.romanenco.gitt.BrowserActivity.java

/**
 * When pull from origin there are several case.
 * 1. We are in TAG (detached head): will inform user to
 * checkout a branch first.//from w w w. j a v a2 s.  c  om
 * 2. Authentication required: ask for password (no passwd save).
 * 3. Anonymous user: just poll.
 */
private void pullFromOrigin() {
    if (current.getUserName() == null) {
        //no authentication required
        current.setState(Repo.State.Busy);
        DAO dao = new DAO(BrowserActivity.this);
        dao.open(true);
        dao.update(current);
        dao.close();
        Intent pull = new Intent(this, GitService.class);
        pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
        pull.putExtra(GitService.REPO, current);
        startService(pull);
        Intent main = new Intent(this, MainActivity.class);
        main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(main);
    } else {
        String req = getString(R.string.passwd_request, current.getUserName());
        final EditText passwd = new EditText(this);
        passwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        AlertDialog dlg = new AlertDialog.Builder(this).setMessage(req)
                .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        String password = passwd.getText().toString();
                        if (TextUtils.isEmpty(password)) {
                            pullFromOrigin();
                        } else {
                            current.setState(Repo.State.Busy);
                            DAO dao = new DAO(BrowserActivity.this);
                            dao.open(true);
                            dao.update(current);
                            dao.close();
                            Intent pull = new Intent(BrowserActivity.this, GitService.class);
                            pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
                            pull.putExtra(GitService.REPO, current);
                            pull.putExtra(GitService.AUTH_PASSWD, password);
                            startService(pull);
                            Intent main = new Intent(BrowserActivity.this, MainActivity.class);
                            main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(main);
                        }
                    }
                }).setNegativeButton(getString(android.R.string.cancel), null).create();
        dlg.setCanceledOnTouchOutside(false);
        dlg.setView(passwd);
        dlg.show();
    }

}

From source file:gov.wa.wsdot.android.wsdot.ui.TwitterFragment.java

private Intent createShareIntent(String mText) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, mText);

    return shareIntent;
}

From source file:com.paranoid.gerrit.PatchSetViewerFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    String tab = null;/*from  w w w .  j av a 2 s.  co m*/
    switch (item.getOrder()) {
    case OWNER:
        tab = CardsFragment.KEY_OWNER;
        break;
    case REVIEWER:
        tab = CardsFragment.KEY_REVIEWER;
    }
    committerObject.setState(tab);
    Intent intent = new Intent(mParent, ReviewTab.class);
    intent.putExtra(CardsFragment.KEY_DEVELOPER, committerObject);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
    startActivity(intent);
    return true;
}

From source file:fi.iki.murgo.irssinotifier.IrssiNotifierActivity.java

public void restart() {
    Intent intent = getIntent();
    overridePendingTransition(0, 0);//from  w ww . j  a  v a2s .  co  m
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();

    overridePendingTransition(0, 0);
    startActivity(intent);
}

From source file:prince.app.ccm.Fragment_Log.java

private void setUpListener() {
    AsyncSession.setCallback(new AsyncCallback() {

        @Override/*w w  w  .  j a va2 s  . c  o  m*/
        public void onPostExecute(boolean result) {
            if (result) {
                saveCredentials();
                Tool.getInstance().modBolPref(Util.SIGN_IN, true);
                Intent intent = new Intent(getActivity(), Activity_Main.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }

            else {
                if (!Tool.getInstance().isConnection()) {
                    Toast.makeText(getActivity(), getResources().getString(R.string.no_connection),
                            Toast.LENGTH_LONG).show();
                }

                else {
                    Toast.makeText(getActivity(), getResources().getString(R.string.user_passwd_error),
                            Toast.LENGTH_LONG).show();
                }

                onCancel();

            }

        }

        @Override
        public void onCancel() {
            mAuthTask = null;
            showProgress(false);

        }

    });
}

From source file:com.adwhirl.AdWhirlLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
    // Sending on an ACTION_DOWN isn't 100% correct... user could have touched
    // down and dragged out. Unlikely though.
    case MotionEvent.ACTION_DOWN:
        Log.d(AdWhirlUtil.ADWHIRL, "Intercepted ACTION_DOWN event");
        if (activeRation != null) {
            countClick();/*from  ww  w.  jav a 2 s.  c o  m*/

            if (activeRation.type == 9) {
                if (custom != null && custom.link != null) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(custom.link));
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    try {
                        if (activityReference == null) {
                            return false;
                        }
                        Activity activity = activityReference.get();
                        if (activity == null) {
                            return false;
                        }
                        activity.startActivity(intent);
                    } catch (Exception e) {
                        Log.w(AdWhirlUtil.ADWHIRL, "Could not handle click to " + custom.link, e);
                    }
                } else {
                    Log.w(AdWhirlUtil.ADWHIRL, "In onInterceptTouchEvent(), but custom or custom.link is null");
                }
            }
            break;
        }
    }

    // Return false so subViews can process event normally.
    return false;
}

From source file:com.android.settings.locationprivacy.LocationPrivacyAdvancedSettings.java

private void addNotification(int id, int textID) {
    String text = getResources().getString(textID);
    Intent intent = new Intent(getActivity(), getActivity().getClass());
    intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, LocationPrivacySettings.class.getName());
    intent.putExtra(PreferenceActivity.EXTRA_NO_HEADERS, true);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pIntent = PendingIntent.getActivity(getActivity(), 0, intent, 0);

    Notification noti = new Notification.Builder(getActivity())
            .setContentTitle(getResources().getString(R.string.lp_webservice_notification_title))
            .setSmallIcon(R.drawable.ic_settings_locationprivacy)
            .setStyle(new Notification.BigTextStyle().bigText(text)).setContentIntent(pIntent)
            .setAutoCancel(true).build();

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            getActivity().NOTIFICATION_SERVICE);
    notificationManager.cancel(WEBSERVICE_ERROR);
    notificationManager.cancel(WEBSERVICE_OK);
    notificationManager.cancel(GOOGLE_PLAY);
    notificationManager.notify(id, noti);
}

From source file:com.easemob.chatuidemo.DemoHXSDKHelper.java

@Override
protected void onConnectionConflict() {
    Intent intent = new Intent(appContext, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("conflict", true);
    appContext.startActivity(intent);//from  w  w  w .  j  av  a  2 s  .  c  o  m
}

From source file:com.easemob.chatuidemo.DemoHXSDKHelper.java

@Override
protected void onCurrentAccountRemoved() {
    Intent intent = new Intent(appContext, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra(Constant.ACCOUNT_REMOVED, true);
    appContext.startActivity(intent);//w  ww .  j  a  va2s .c o  m
}