Example usage for android.content Intent FLAG_ACTIVITY_NO_ANIMATION

List of usage examples for android.content Intent FLAG_ACTIVITY_NO_ANIMATION

Introduction

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

Prototype

int FLAG_ACTIVITY_NO_ANIMATION

To view the source code for android.content Intent FLAG_ACTIVITY_NO_ANIMATION.

Click Source Link

Document

If set in an Intent passed to Context#startActivity Context.startActivity() , this flag will prevent the system from applying an activity transition animation to go to the next activity state.

Usage

From source file:io.coldstart.android.TrapListActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.GCMStatus: {
        subscribeToMessages();//from w w w. j  a v  a2s. co m
        return true;
    }

    case R.id.ChangeKey: {
        SharedPreferences.Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
        editor.putBoolean("firstRun", true);
        editor.putString("APIKey", "");
        editor.putString("keyPassword", "");
        editor.commit();
        Intent intent = getIntent();
        overridePendingTransition(0, 0);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        finish();
        overridePendingTransition(0, 0);
        startActivity(intent);
        return true;
    }

    case R.id.PauseAlerts: {
        new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert)
                .setTitle("Delete Traps for selected host?")
                .setMessage(
                        "Are you sure you want to logout?\nYou'll no longer receive any alerts, they won't be cached on the server and the app will close.")
                .setPositiveButton("Yes, Logout", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        Log.i("onOptionsItemSelected", "Logging Out");
                        (new Thread() {
                            public void run() {
                                API api = new API();

                                try {
                                    if (api.logoutGCMAccount(settings.getString("APIKey", ""),
                                            settings.getString("keyPassword", ""), securityID)) {
                                        //We successfully logged out
                                        runOnUiThread(new Runnable() {
                                            public void run() {
                                                gcmStatus.setIcon(R.drawable.ic_action_gcm_failed);
                                                Toast.makeText(getApplicationContext(),
                                                        "Succesfully logged out. Tap the GCM icon or relaunch app to login again",
                                                        Toast.LENGTH_SHORT).show();
                                            }
                                        });
                                    } else {
                                        //TODO Popup to the user that there was a problem logging out
                                        runOnUiThread(new Runnable() {
                                            public void run() {
                                                gcmStatus.setIcon(R.drawable.ic_action_gcm_failed);
                                                Toast.makeText(getApplicationContext(),
                                                        "There was a problem logging out.", Toast.LENGTH_SHORT)
                                                        .show();
                                            }
                                        });
                                    }

                                    runOnUiThread(new Runnable() {
                                        public void run() {
                                            TrapListActivity.this.invalidateOptionsMenu();
                                        }
                                    });
                                } catch (Exception e) {
                                    //TODO this is probably pretty bad!
                                    e.printStackTrace();
                                }
                            }
                        }).start();
                    }
                }).setNegativeButton("No", null).show();
        return true;
    }

    case R.id.Settings: {
        Intent SettingsIntent = new Intent(TrapListActivity.this, SettingsFragment.class);
        this.startActivityForResult(SettingsIntent, DISPLAY_SETTINGS);
        return true;
    }

    case R.id.SeeAPIKey: {
        if (dialogFragment != null)
            dialogFragment.dismiss();

        FragmentTransaction ft = getFragmentManager().beginTransaction();
        Fragment prev = getFragmentManager().findFragmentByTag("dialog");
        if (prev != null) {
            ft.remove(prev);
            Log.i("prev", "Removing");
        }
        ft.addToBackStack(null);

        // Create and show the dialog.
        dialogFragment = ViewAPIKeyDialog.newInstance(settings.getString("APIKey", ""));
        dialogFragment.setCancelable(true);
        dialogFragment.show(ft, "dialog");

        return true;
    }

    /*case R.id.Filters:
    {
        if(dialogFragment != null)
            dialogFragment.dismiss();
            
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        Fragment prev = getFragmentManager().findFragmentByTag("dialog");
        if (prev != null)
        {
            ft.remove(prev);
            Log.i("prev","Removing");
        }
        ft.addToBackStack(null);
            
        // Create and show the dialog.
        dialogFragment = HostFilterDialog.newInstance();
        dialogFragment.setCancelable(true);
        dialogFragment.show(ft, "dialog");
            
        return true;
    }*/
    }

    return false;
}

From source file:com.money.manager.ex.MainActivity.java

/**
 * for the change setting restart process application
 *///from  w w w.j  ava  2s. c om
public void restartActivity() {
    if (mRestartActivity) {
        Intent intent = getIntent();
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        // finish this activity
        finish();
        // restart
        startActivity(intent);
        // kill process
        android.os.Process.killProcess(android.os.Process.myPid());
    }
    // set state a false
    setRestartActivity(false);
}

From source file:com.silentcircle.contacts.list.ShortcutIntentBuilder.java

private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName,
        String lookupKey, byte[] bitmapData) {
    Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);

    Intent shortcutIntent = new Intent(ContactsContract.QuickContact.ACTION_QUICK_CONTACT);

    // When starting from the launcher, start in a new, cleared task.
    // CLEAR_WHEN_TASK_RESET cannot reset the root of a task, so we
    // clear the whole thing preemptively here since QuickContactActivity will
    // finish itself when launching other detail activities. We need to use
    // Intent.FLAG_ACTIVITY_NO_ANIMATION since not all versions of launcher will respect
    // the INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION intent extra.
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    // Tell the launcher to not do its animation, because we are doing our own
    shortcutIntent.putExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION, true);

    shortcutIntent.setDataAndType(contactUri, contentType);
    shortcutIntent.putExtra(ContactsContract.QuickContact.EXTRA_EXCLUDE_MIMES, (String[]) null);

    final Bitmap icon = generateQuickContactIcon(drawable);

    Intent intent = new Intent();
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    if (TextUtils.isEmpty(displayName)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.missing_name));
    } else {/*from ww  w .  j a v  a  2  s.c om*/
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName);
    }

    mListener.onShortcutIntentCreated(contactUri, intent);
}

From source file:com.glacialsoftware.googolplex.GoogolplexDisplayActivity.java

@Override
public void doRecreateActivity() {

    Bundle savedInstanceState = new Bundle();
    saveInstanceState(savedInstanceState);

    Intent intent = getIntent();/*from   ww  w  . j ava  2  s.  c  o  m*/
    intent.putExtra("com.glacialsoftware.googolplex.manualSavedInstanceState", savedInstanceState);

    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();
    overridePendingTransition(0, 0);

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

From source file:com.vuze.android.remote.activity.IntentHandler.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int itemId = item.getItemId();
    if (itemId == R.id.action_add_profile) {
        Intent myIntent = new Intent(getIntent());
        myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        myIntent.setClass(IntentHandler.this, LoginActivity.class);
        startActivity(myIntent);//from   w  w  w.  ja  va  2  s  . com
        return true;
    } else if (itemId == R.id.action_adv_login) {
        return AndroidUtils.showDialog(new DialogFragmentGenericRemoteProfile(), getSupportFragmentManager(),
                "GenericRemoteProfile");
    } else if (itemId == R.id.action_about) {
        return AndroidUtils.showDialog(new DialogFragmentAbout(), getSupportFragmentManager(), "About");
    } else if (itemId == R.id.action_export_prefs) {
        appPreferences.exportPrefs(this);
    } else if (itemId == R.id.action_import_prefs) {
        AndroidUtils.openFileChooser(this, "application/octet-stream",
                TorrentViewActivity.FILECHOOSER_RESULTCODE);
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.android.contacts.common.list.ShortcutIntentBuilder.java

private void createContactShortcutIntent(Uri contactUri, String contentType, String displayName,
        String lookupKey, byte[] bitmapData) {
    Drawable drawable = getPhotoDrawable(bitmapData, displayName, lookupKey);

    // Use an implicit intent without a package name set. It is reasonable for a disambiguation
    // dialog to appear when opening QuickContacts from the launcher. Plus, this will be more
    // resistant to future package name changes done to Contacts.
    Intent shortcutIntent = new Intent(ContactsContract.QuickContact.ACTION_QUICK_CONTACT);

    // When starting from the launcher, start in a new, cleared task.
    // CLEAR_WHEN_TASK_RESET cannot reset the root of a task, so we
    // clear the whole thing preemptively here since QuickContactActivity will
    // finish itself when launching other detail activities. We need to use
    // Intent.FLAG_ACTIVITY_NO_ANIMATION since not all versions of launcher will respect
    // the INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION intent extra.
    shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK
            | Intent.FLAG_ACTIVITY_NO_ANIMATION);

    // Tell the launcher to not do its animation, because we are doing our own
    shortcutIntent.putExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION, true);

    shortcutIntent.setDataAndType(contactUri, contentType);
    shortcutIntent.putExtra(ContactsContract.QuickContact.EXTRA_EXCLUDE_MIMES, (String[]) null);

    final Bitmap icon = generateQuickContactIcon(drawable);

    Intent intent = new Intent();
    intent.putExtra(Intent.EXTRA_SHORTCUT_ICON, icon);
    intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
    if (TextUtils.isEmpty(displayName)) {
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, mContext.getResources().getString(R.string.missing_name));
    } else {//from w w w . j av  a  2 s.  c  o  m
        intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, displayName);
    }

    mListener.onShortcutIntentCreated(contactUri, intent);
}

From source file:org.gdg.frisbee.android.common.GdgNavDrawerActivity.java

private void navigateTo(Class<? extends GdgActivity> activityClass, Bundle additional) {
    if (this.getClass().equals(activityClass) && !(this instanceof TaggedEventSeriesActivity)) {
        return;/*from  w w  w.j a  v  a  2s  . c  om*/
    }

    Intent i = new Intent(GdgNavDrawerActivity.this, activityClass);
    i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

    if (additional != null) {
        i.putExtras(additional);
    }

    startActivity(i);
    mDrawerLayout.closeDrawers();
}

From source file:id.ridon.keude.Keude.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    switch (requestCode) {
    case REQUEST_APPDETAILS:
        break;//from   w  w w  .j  a  va2 s  .c om
    case REQUEST_MANAGEREPOS:
        if (data != null && data.hasExtra(ManageReposActivity.REQUEST_UPDATE)) {
            AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this);
            ask_alrt.setTitle(getString(R.string.repo_update_title));
            ask_alrt.setIcon(android.R.drawable.ic_menu_rotate);
            ask_alrt.setMessage(getString(R.string.repo_alrt));
            ask_alrt.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    updateRepos();
                }
            });
            ask_alrt.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    // do nothing
                }
            });
            AlertDialog alert = ask_alrt.create();
            alert.show();
        }
        break;
    case REQUEST_PREFS:
        // The automatic update settings may have changed, so reschedule (or
        // unschedule) the service accordingly. It's cheap, so no need to
        // check if the particular setting has actually been changed.
        UpdateService.schedule(getBaseContext());

        if ((resultCode & PreferencesActivity.RESULT_RESTART) != 0) {
            ((KeudeApp) getApplication()).reloadTheme();
            final Intent intent = getIntent();
            overridePendingTransition(0, 0);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            finish();
            overridePendingTransition(0, 0);
            startActivity(intent);
        }
        break;
    case REQUEST_ENABLE_BLUETOOTH:
        fdroidApp.sendViaBluetooth(this, resultCode, "id.ridon.keude");
        break;
    }
}

From source file:org.mozilla.gecko.fxa.activities.FxAccountStatusFragment.java

@Override
public boolean onPreferenceClick(Preference preference) {
    if (preference == needsPasswordPreference) {
        Intent intent = new Intent(getActivity(), FxAccountUpdateCredentialsActivity.class);
        final Bundle extras = getExtrasForAccount();
        if (extras != null) {
            intent.putExtras(extras);/*  ww  w.  j ava2  s .c om*/
        }
        // Per http://stackoverflow.com/a/8992365, this triggers a known bug with
        // the soft keyboard not being shown for the started activity. Why, Android, why?
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);

        return true;
    }

    if (preference == needsFinishMigratingPreference) {
        final Intent intent = new Intent(getActivity(), FxAccountFinishMigratingActivity.class);
        final Bundle extras = getExtrasForAccount();
        if (extras != null) {
            intent.putExtras(extras);
        }
        // Per http://stackoverflow.com/a/8992365, this triggers a known bug with
        // the soft keyboard not being shown for the started activity. Why, Android, why?
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);

        return true;
    }

    if (preference == needsVerificationPreference) {
        FxAccountCodeResender.resendCode(getActivity().getApplicationContext(), fxAccount);

        Intent intent = new Intent(getActivity(), FxAccountConfirmAccountActivity.class);
        // Per http://stackoverflow.com/a/8992365, this triggers a known bug with
        // the soft keyboard not being shown for the started activity. Why, Android, why?
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);

        return true;
    }

    if (preference == bookmarksPreference || preference == historyPreference
            || preference == passwordsPreference || preference == tabsPreference) {
        saveEngineSelections();
        return true;
    }

    if (preference == morePreference) {
        getActivity().openOptionsMenu();
        return true;
    }

    if (preference == syncNowPreference) {
        if (fxAccount != null) {
            FirefoxAccounts.requestSync(fxAccount.getAndroidAccount(), FirefoxAccounts.FORCE, null, null);
        }
        return true;
    }

    return false;
}

From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();
    if (id == R.id.action_view_as_grid) {
        Intent i = new Intent(POIMapActivity.this, POIGridActivity.class);

        i.putExtra("playOn", mActionPlay);

        i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        // finish();
        overridePendingTransition(0, 0);

        startActivityForResult(i, 1);/*from ww w.  j  ava 2 s.  co m*/
        overridePendingTransition(0, 0);

    } else if (id == R.id.action_directions) {

        if (mActionDirections == 1) { // cancel directions action
            item.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        } else if (mActionDirections == 0) { // set directions action on

            item.setIcon(R.drawable.ic_action_directions_pressed);
            mActionDirections = 1;

            gmm.handleMapWarningMessages(POIMapActivity.this, tvMapMessage);
            if (gmm.myLocationEnabled && gmm.internetEnabled) {
                Toast.makeText(POIMapActivity.this,
                        POIMapActivity.this.getResources().getString(R.string.tap_route_destination),
                        Toast.LENGTH_SHORT).show();

            } else {
                tvMapMessage.setBackgroundColor(
                        POIMapActivity.this.getResources().getColor(R.color.red_transparent));

                item.setIcon(R.drawable.ic_action_directions);
                mActionDirections = 0;
                tvMapDirectionsInfo.setVisibility(View.INVISIBLE);

            }
        } else { // mActionDirections == 3
            item.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        }

    } else if (id == R.id.action_play) {

        if (mActionPlay) { // cancel play mode
            gmm.addAllMarkers(POIMapActivity.this);
            item.setIcon(R.drawable.ic_action_play);
            mActionPlay = false;

            miDirections.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        } else {
            gmm.addPlayMarkers(POIMapActivity.this);
            item.setIcon(R.drawable.ic_action_pause_red);
            if (gmm.activePOIMarker != null) {
                drawUserDestRoute(gmm.activePOIMarker.getPosition());
            }
            mActionPlay = true;

        }

    } else if (id == R.id.action_google_map_type) {
        // get google map type names
        String[] googleMapTypeNames = getResources().getStringArray(R.array.google_map_type_names);

        // creating and Building the Dialog
        AlertDialog.Builder builderMapType = new AlertDialog.Builder(this);
        builderMapType.setTitle(getResources().getString(R.string.action_google_map_type));
        builderMapType.setSingleChoiceItems(googleMapTypeNames, selectedMapType,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {

                        if (item != selectedMapType) {
                            switchGoogleMapType(item);
                            // save selected type in settings
                            SharedPreferences preferences = PreferenceManager
                                    .getDefaultSharedPreferences(POIMapActivity.this);
                            SharedPreferences.Editor editor = preferences.edit();
                            editor.putString("googleMapType", String.valueOf(item));
                            editor.commit();
                        }
                        mapTypeDialog.dismiss();
                    }
                });
        mapTypeDialog = builderMapType.create();
        mapTypeDialog.show();

    } else if (id == R.id.action_legal_notices) {

        String licenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder licenseDialog = new AlertDialog.Builder(POIMapActivity.this);
        licenseDialog.setTitle(getString(R.string.action_legal_notices));
        licenseDialog.setMessage(licenseInfo);
        licenseDialog.show();

    } else if (id == R.id.action_scan_qr_code) {

        handleQRcodeScanRequest();

    } else if (id == R.id.action_about) {
        String about = getString(R.string.about_application);
        AlertDialog alertDialog;
        alertDialog = new AlertDialog.Builder(POIMapActivity.this).create();

        alertDialog.setTitle(getString(R.string.action_about));
        alertDialog.setMessage(Html.fromHtml(about));

        alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
        alertDialog.show();
    }
    return super.onOptionsItemSelected(item);
}