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:com.vuze.android.remote.activity.DrawerActivity.java

@SuppressLint("NewApi")
public void onCreate_setupDrawer() {
    setupProfileSpinner();/*from   w  ww .  j  a v  a 2s. c o m*/

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            DrawerActivity.this.onDrawerClosed(view);
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View view) {
            super.onDrawerOpened(view);
            DrawerActivity.this.onDrawerOpened(view);
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerView = findViewById(R.id.drawer_view);
    ListView mDrawerList = (ListView) findViewById(R.id.drawer_listview);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mDrawerLayout.setElevation(30);
    }

    Resources res = getResources();
    // Set the adapter for the list view
    mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, R.id.title,
            new CharSequence[] { res.getText(R.string.drawer_torrents), res.getText(R.string.drawer_rcm),
                    res.getText(R.string.drawer_logout), }));
    // Set the list's click listener
    mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mDrawerLayout.closeDrawer(mDrawerView);
            switch (position) {
            case 0: {
                Intent intent = new Intent(Intent.ACTION_VIEW, null, DrawerActivity.this,
                        TorrentViewActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                intent.putExtra(SessionInfoManager.BUNDLE_KEY, getSessionInfo().getRemoteProfile().getID());
                startActivity(intent);
                break;
            }

            case 1: {
                Intent intent = new Intent(Intent.ACTION_VIEW, null, DrawerActivity.this, RcmActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                intent.putExtra(SessionInfoManager.BUNDLE_KEY, getSessionInfo().getRemoteProfile().getID());
                startActivity(intent);
                break;
            }

            case 2: {
                RemoteUtils.openRemoteList(DrawerActivity.this);
                SessionInfoManager.removeSessionInfo(getSessionInfo().getRemoteProfile().getID());
                finish();
                break;
            }
            }
        }
    });
}

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

/** Called when the activity is first created. */
@Override//  w w  w  .  j  ava2  s. c om
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_LEFT_ICON);
    setContentView(R.layout.layout_report_map);
    getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon_mes_rapports);

    map = (MapView) findViewById(R.id.MapView_mymap);
    map.setBuiltInZoomControls(true);
    tabs = (RadioGroup) findViewById(R.id.RadioGroup_tabs_map);

    // mOverlay = new SimpleItemizedOverlay(getResources().getDrawable(R.drawable.map_cursor), this, map);
    map.getOverlays().add(mOverlay);
    map.setSatellite(false);

    tbmap = (ToggleButton) findViewById(R.id.ToggleButton_Map);
    tbmap.setChecked(true);
    tbmap.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                tbmap.setChecked(true);
                Intent i = new Intent(MyIncidentsActivityMap.this, MyIncidentsActivity.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);
            }

        }
    });

    if (getIntent().getExtras().getInt("tab") != 0) {

        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);
        }

        // setMapForTab(gettabIndex(tabs.getCheckedRadioButtonId()));

    } else {

        // launch request
        try {
            AVService.getInstance(this)
                    .postJSON(new JSONArray().put(new JSONObject()
                            .put(JsonData.PARAM_REQUEST, JsonData.VALUE_REQUEST_GET_MY_INCIDENTS)
                            .put(JsonData.PARAM_UDID, Utils.getUdid(this))), this);
            showDialog(DIALOG_PROGRESS);
        } catch (JSONException e) {
            Log.e(Constants.PROJECT_TAG, "error launching My Incidents", e);
        }
    }

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

    tabs.check(getId());

    if (checked == R.id.Tab_Map_ongoing) {
        setMapForTab(gettabIndex(checked));
    }

}

From source file:pl.kodujdlapolski.na4lapy.ui.drawer.DrawerActivityHandler.java

protected boolean onNavigationItemSelected(MenuItem item) {

    Intent intent = null;/* w w  w.  ja  v a 2  s .co m*/
    int id = item.getItemId();
    Class<?> clazz = activity.getClass();

    if (id == R.id.browser && !(clazz.equals(SingleBrowseActivity.class))) {
        intent = new Intent(context, SingleBrowseActivity.class);
    } else if (id == R.id.favourites && !(clazz.equals(ListBrowseActivity.class))) {
        intent = new Intent(context, ListBrowseActivity.class);
    } else if (id == R.id.preferences && !(clazz.equals(PreferencesActivity.class))) {
        intent = new Intent(context, PreferencesActivity.class);
    } else if (id == R.id.aboutShelter && !(clazz.equals(AboutShelterActivity.class))) {
        intent = new Intent(context, AboutShelterActivity.class);
        Shelter shelter = new Shelter();
        shelter.setId(1L);
        intent.putExtra(AboutShelterActivity.EXTRA_SHELTER_ID, 1l);
    } else if (id == R.id.makePayment && !(clazz.equals(PaymentActivity.class))) {
        intent = new Intent(context, PaymentActivity.class);
        intent.putExtra(PaymentContract.KEY_SHELTER_ID, 1L);
    } else if (id == R.id.settings && !(clazz.equals(SettingsActivity.class))) {
        intent = new Intent(context, SettingsActivity.class);
    }
    if (intent != null) {
        int flags = Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT;
        if (clazz.equals(SingleBrowseActivity.class)) {
            flags = flags | (Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        }
        intent.setFlags(flags);
        activity.startActivity(intent);
        activity.overridePendingTransition(0, 0);
    }
    return true;
}

From source file:id.zelory.codepolitan.ui.fragment.ChooseCategoryFragment.java

private void submit(View view) {
    Intent intent = new Intent(getActivity(), MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    startActivity(intent);//w  w w.j  ava2s .c  om
    getActivity().finish();
}

From source file:eu.chainfire.geolog.service.BackgroundService.java

@SuppressLint("NewApi")
@Override/*from   w w  w.  j ava  2 s . com*/
public void onCreate() {
    super.onCreate();
    Debug.log("Service created");

    if (thread == null) {
        Debug.log("Launching thread");
        thread = new ServiceThread();
        thread.setContext(getApplicationContext());
        thread.start();
    }

    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "GeoLog Wakelock");

    Intent i = new Intent();
    i.setAction(Intent.ACTION_MAIN);
    i.addCategory(Intent.CATEGORY_LAUNCHER);
    i.setClass(this, MainActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NEW_TASK);
    notificationIntent = PendingIntent.getActivity(this, 0, i, 0);

    notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    notificationBuilder = (new Notification.Builder(this)).setSmallIcon(R.drawable.ic_stat_service)
            .setContentIntent(notificationIntent).setWhen(System.currentTimeMillis()).setAutoCancel(false)
            .setOngoing(true).setContentTitle(getString(R.string.service_title))
            .setContentText(getString(R.string.service_waiting));

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        notificationBuilder.setShowWhen(false);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        /* quick turn off, maybe ? if added, make sure to add a button to preferences to disable these buttons
        notificationBuilder.
           setPriority(Notification.PRIORITY_MAX).
           addAction(0, "A", notificationIntent).
           addAction(0, "B", notificationIntent).
           addAction(0, "C", notificationIntent);
        */
    }

    updateNotification();
}

From source file:org.catnut.ui.HelloActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mApp = CatnutApp.getTingtingApp();//from ww  w.j ava2s.co m
    mPreferences = mApp.getPreferences();
    fetch500px();
    // ?????????
    AccessToken accessToken = mApp.getAccessToken();
    if (accessToken == null || System.currentTimeMillis() > accessToken.expires_in) {
        mApp.invalidateAccessToken();
        Toast.makeText(this, getString(R.string.not_yet_auth), Toast.LENGTH_SHORT).show();
        startActivity(new Intent(this, NoHistoryActivity.class));
    } else {
        // ?
        CatnutUtils.checkout(false, this, mPreferences);
        // ?
        if (getIntent().hasExtra(TAG)) {
            init();
        } else if (ACTION_FROM_GRID.equals(getIntent().getAction())) {
            mTargetFromGrid = new Image();
            mTargetFromGrid.url = getIntent().getStringExtra(Photo.image_url);
            mTargetFromGrid.name = getIntent().getStringExtra(Photo.name);
            init();
        } else {
            if (CatnutApp.getBoolean(R.string.pref_enter_home_directly, R.bool.pref_enter_home_directly)) {
                startActivity(new Intent(this, MainActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
                        | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION));
            } else {
                init();
            }
        }
    }
}

From source file:com.bluros.music.utils.NavigationUtils.java

public static void navigateToNowplaying(Activity context, boolean withAnimations) {

    final Intent intent = new Intent(context, NowPlayingActivity.class);
    if (!PreferencesUtility.getInstance(context).getSystemAnimations()) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    }//from   w  ww  .j av  a2s .  c om
    context.startActivity(intent);
}

From source file:org.cryptocall.ui.BaseActivity.java

/**
 * Executed onCreate of Activity/*  w  ww . j a va2s.  co m*/
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Start wizard for first use
    if (PreferencesHelper.getFirstStart(this)) {
        Intent wizardIntent = new Intent(this, WizardActivity.class);
        wizardIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(wizardIntent);
        finish();
    }

    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.base_activity);

    mActivity = this;

    mActionBar = getSupportActionBar();
    mActionBar.setDisplayShowTitleEnabled(true);
    mActionBar.setDisplayHomeAsUpEnabled(false);
    mActionBar.setHomeButtonEnabled(false);
    mActionBar.setSubtitle(R.string.app_subtitle);

    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mTabContacts = getSupportActionBar().newTab();
    mTabInformation = getSupportActionBar().newTab();
    mTabExchange = getSupportActionBar().newTab();

    mTabContacts.setTabListener(new TabListener<ContactsFragment>(this, "contacts", ContactsFragment.class));
    mTabInformation.setTabListener(
            new TabListener<BaseInformationFragment>(this, "information", BaseInformationFragment.class));
    mTabExchange.setTabListener(
            new TabListener<BaseExchangeFragment>(this, "exchange", BaseExchangeFragment.class));

    mTabContacts.setText(getString(R.string.base_tab_contacts));
    mTabInformation.setText(getString(R.string.base_tab_information));
    mTabExchange.setText(getString(R.string.base_tab_exchange));

    mActionBar.addTab(mTabContacts);
    mActionBar.addTab(mTabInformation);
    mActionBar.addTab(mTabExchange);

    // add manual connection fragment when in debug mode
    if (Constants.DEBUG) {
        mTabManualConnection = getSupportActionBar().newTab();
        mTabManualConnection.setTabListener(new TabListener<BaseManualConnectionFragment>(this, "manual",
                BaseManualConnectionFragment.class));
        mTabManualConnection.setText(getString(R.string.base_tab_manual_connection));
        mActionBar.addTab(mTabManualConnection);
    }
}

From source file:com.klinker.android.twitter.listeners.MainDrawerClickListener.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    context.sendBroadcast(new Intent("com.klinker.android.twitter.MARK_POSITION"));
    if (i < 3) {
        if (MainDrawerArrayAdapter.current < 3) {
            new Handler().postDelayed(new Runnable() {
                @Override//from   w w  w.  j  a v  a  2 s.  c o  m
                public void run() {
                    try {
                        drawer.closeDrawer(Gravity.START);
                    } catch (Exception e) {
                        // landscape mode
                    }
                }
            }, noWait ? 0 : 300);

            viewPager.setCurrentItem(i + extraPages, true);
        } else {
            final int pos = i;
            try {
                drawer.closeDrawer(Gravity.START);
            } catch (Exception e) {
                // landscape mode
            }

            Intent intent = new Intent(context, MainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            intent.putExtra("page_to_open", pos + extraPages);
            intent.putExtra("from_drawer", true);

            sharedPreferences.edit().putBoolean("should_refresh", false).commit();

            final Intent fIntent = intent;
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        context.startActivity(fIntent);
                        ((Activity) context).overridePendingTransition(0, 0);
                        ((Activity) context).finish();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, noWait ? 0 : 400);

        }
    } else {
        final int pos = i;
        try {
            drawer.closeDrawer(Gravity.START);
        } catch (Exception e) {
            // landscape mode
        }
        Intent intent = null;

        switch (pos) {
        case 3:
            intent = new Intent(context, DiscoverPager.class);
            break;
        case 4:
            intent = new Intent(context, ListsActivity.class);
            break;
        case 5:
            intent = new Intent(context, FavoriteUsersActivity.class);
            break;
        case 6:
            intent = new Intent(context, RetweetActivity.class);
            break;
        case 7:
            intent = new Intent(context, FavoritesActivity.class);
            break;
        case 8:
            intent = new Intent(context, SavedSearchesActivity.class);
            break;
        }

        final Intent fIntent = intent;

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    context.startActivity(fIntent);
                    ((Activity) context).finish();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, noWait ? 0 : 400);

    }

}

From source file:com.daiv.android.twitter.listeners.MainDrawerClickListener.java

@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
    context.sendBroadcast(new Intent("com.daiv.android.twitter.MARK_POSITION"));

    // we will increment until we find one that is in the set of shown elements
    for (int index = 0; index <= i; index++) {
        if (!set.contains(index + "")) {
            i++;//w ww  .j ava  2  s  .  co  m
        }
    }

    if (i < swipablePages) {
        if (MainDrawerArrayAdapter.current < swipablePages) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        drawer.closeDrawer(Gravity.START);
                    } catch (Exception e) {
                        // landscape mode
                    }
                }
            }, noWait ? 0 : 300);

            viewPager.setCurrentItem(i, true);
        } else {
            final int pos = i;
            try {
                drawer.closeDrawer(Gravity.START);
            } catch (Exception e) {
                // landscape mode
            }

            Intent intent = new Intent(context, MainActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            intent.putExtra("page_to_open", pos);
            intent.putExtra("from_drawer", true);

            sharedPreferences.edit().putBoolean("should_refresh", false).commit();

            final Intent fIntent = intent;
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        context.startActivity(fIntent);
                        ((Activity) context).overridePendingTransition(0, 0);
                        ((Activity) context).finish();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, noWait ? 0 : 400);

        }
    } else {
        final int pos = i;
        try {
            drawer.closeDrawer(Gravity.START);
        } catch (Exception e) {
            // landscape mode
        }

        Intent intent = null;

        final Intent fIntent = intent;

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                try {
                    context.startActivity(fIntent);
                    ((Activity) context).overridePendingTransition(0, 0);
                    ((Activity) context).finish();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }, noWait ? 0 : 400);

    }

}