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:org.mozilla.gecko.sync.setup.activities.SetupSyncActivity.java

public void manualClickHandler(View target) {
    Intent accountIntent = new Intent(this, AccountActivity.class);
    accountIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    startActivity(accountIntent);/*w ww.ja  v a  2 s. com*/
    overridePendingTransition(0, 0);
}

From source file:com.techmighty.baseplayer.utils.NavigationUtils.java

@TargetApi(21)
public static void navigateToPlaylistDetail(Activity context, String action, long firstAlbumID,
        String playlistName, int foregroundcolor, long playlistID, ArrayList<Pair> transitionViews) {
    final Intent intent = new Intent(context, PlaylistDetailActivity.class);
    if (!PreferencesUtility.getInstance(context).getSystemAnimations()) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    }//  w w w. j  a v  a  2s.  c om
    intent.setAction(action);
    intent.putExtra(Constants.PLAYLIST_ID, playlistID);
    intent.putExtra(Constants.PLAYLIST_FOREGROUND_COLOR, foregroundcolor);
    intent.putExtra(Constants.ALBUM_ID, firstAlbumID);
    intent.putExtra(Constants.PLAYLIST_NAME, playlistName);

    if (BasePlayerUtils.isLollipop() && PreferencesUtility.getInstance(context).getAnimations()) {
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MainActivity.getInstance(),
                transitionViews.get(0), transitionViews.get(1), transitionViews.get(2));
        context.startActivity(intent, options.toBundle());
    } else {
        context.startActivity(intent);
    }
}

From source file:com.devalladolid.musictoday.utils.NavigationUtils.java

@TargetApi(21)
public static void navigateToPlaylistDetail(Activity context, String action, long firstAlbumID,
        String playlistName, int foregroundcolor, long playlistID, ArrayList<Pair> transitionViews) {
    final Intent intent = new Intent(context, PlaylistDetailActivity.class);
    if (!PreferencesUtility.getInstance(context).getSystemAnimations()) {
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    }//w w  w.ja v a2s .c  o m
    intent.setAction(action);
    intent.putExtra(Constants.PLAYLIST_ID, playlistID);
    intent.putExtra(Constants.PLAYLIST_FOREGROUND_COLOR, foregroundcolor);
    intent.putExtra(Constants.ALBUM_ID, firstAlbumID);
    intent.putExtra(Constants.PLAYLIST_NAME, playlistName);
    intent.putExtra(Constants.ACTIVITY_TRANSITION, transitionViews != null);

    if (transitionViews != null && TimberUtils.isLollipop()
            && PreferencesUtility.getInstance(context).getAnimations()) {
        ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(MainActivity.getInstance(),
                transitionViews.get(0), transitionViews.get(1), transitionViews.get(2));
        context.startActivityForResult(intent, Constants.ACTION_DELETE_PLAYLIST, options.toBundle());
    } else {
        context.startActivityForResult(intent, Constants.ACTION_DELETE_PLAYLIST);
    }
}

From source file:de.baumann.browser.helper.helper_main.java

public static void switchToActivity(Activity from, Class to, String Extra, boolean finishFromActivity) {
    Intent intent = new Intent(from, to);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    intent.putExtra("url", Extra);
    from.startActivity(intent);/*from www .j  a v a2  s.  c  o m*/
    if (finishFromActivity) {
        from.finish();
    }
}

From source file:org.fdroid.fdroid.MainActivity.java

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

    switch (requestCode) {
    case REQUEST_APPDETAILS:
        break;/*www  .j  av a 2 s  .c  o  m*/
    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) {
            ((FDroidApp) 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, "org.fdroid.fdroid");
        break;
    }

    if (requestCode == com.skubit.Utils.AUTHORIZATION_CODE && data != null
            && !TextUtils.isEmpty(data.getStringExtra("response"))) {
        com.skubit.Utils.createNewAccount(this, data);
    } else if (requestCode == com.skubit.Utils.PLAY_CODE) {
        doLogin = true;
        bindService(com.skubit.Utils.getBillingServiceIntent(), mServiceConn, Context.BIND_AUTO_CREATE);
    }
}

From source file:com.example.RITW.proximity.FeaturesActivity.java

private void setupPluginsInDrawer(final ViewGroup container) {
    final LayoutInflater inflater = LayoutInflater.from(this);
    final PackageManager pm = getPackageManager();

    // look for Master Control Panel
    final Intent mcpIntent = new Intent(Intent.ACTION_MAIN);
    mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS);
    final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0);

    // configure link to Master Control Panel
    //final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp);
    if (mcpInfo == null) {
        //   mcpItem.setTextColor(Color.GRAY);
        ColorMatrix grayscale = new ColorMatrix();
        grayscale.setSaturation(0.0f);/* ww  w.  ja v a2  s. c o m*/
        //   mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale));
    }
    /*mcpItem.setOnClickListener(new View.OnClickListener() {
       @Override
       public void onClick(final View v) {
    Intent action = mcpIntent;
    if (mcpInfo == null)
       action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI));
    action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    try {
       startActivity(action);
    } catch (final ActivityNotFoundException e) {
       Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show();
    }
    mDrawerLayout.closeDrawers();
       }
    });*/

    // look for other plug-ins
    final Intent utilsIntent = new Intent(Intent.ACTION_MAIN);
    utilsIntent.addCategory(UTILS_CATEGORY);

    final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0);
    for (final ResolveInfo info : appList) {
        final View item = inflater.inflate(R.layout.drawer_plugin, container, false);
        final ImageView icon = (ImageView) item.findViewById(android.R.id.icon);
        final TextView label = (TextView) item.findViewById(android.R.id.text1);

        label.setText(info.loadLabel(pm));
        icon.setImageDrawable(info.loadIcon(pm));
        item.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                final Intent intent = new Intent();
                intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name));
                intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                startActivity(intent);
                mDrawerLayout.closeDrawers();
            }
        });
        container.addView(item);
    }
}

From source file:com.aero2.android.DefaultActivities.SmogMapActivity.java

public void refreshActivity() {
    Intent intent = getIntent();/*www .j a  va  2  s  . c  o  m*/
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();
    overridePendingTransition(0, 0);
    startActivity(intent);
}

From source file:org.wheelmap.android.activity.POIsListActivity.java

@Override
public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.switch_maps) {

        Intent intent = new Intent(POIsListActivity.this, POIsMapsforgeActivity.class);
        // intent.putExtra(POIsMapsforgeActivity.EXTRA_NO_RETRIEVAL, false);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);/*from  w  w  w.  j  a  v  a2 s .  c om*/
        overridePendingTransition(0, 0);
        tracker.trackEvent("Clicks", // Category
                "Button", // Action
                "SwitchMaps", // Label
                0); // Value

    }
}

From source file:org.gateshipone.malp.application.background.NotificationManager.java

public synchronized void updateNotification(MPDTrack track, MPDCurrentStatus.MPD_PLAYBACK_STATE state) {
    if (track != null) {
        mNotificationBuilder = new NotificationCompat.Builder(mService);

        // Open application intent
        Intent contentIntent = new Intent(mService, MainActivity.class);
        contentIntent.putExtra(MainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW,
                MainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW_NOWPLAYINGVIEW);
        contentIntent.addFlags(//from   www .j a  v  a  2  s  .  com
                Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK
                        | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_HISTORY);
        PendingIntent contentPendingIntent = PendingIntent.getActivity(mService, INTENT_OPENGUI, contentIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        mNotificationBuilder.setContentIntent(contentPendingIntent);

        // Set pendingintents
        // Previous song action
        Intent prevIntent = new Intent(BackgroundService.ACTION_PREVIOUS);
        PendingIntent prevPendingIntent = PendingIntent.getBroadcast(mService, INTENT_PREVIOUS, prevIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Action prevAction = new NotificationCompat.Action.Builder(
                R.drawable.ic_skip_previous_48dp, "Previous", prevPendingIntent).build();

        // Pause/Play action
        PendingIntent playPauseIntent;
        int playPauseIcon;
        if (state == MPDCurrentStatus.MPD_PLAYBACK_STATE.MPD_PLAYING) {
            Intent pauseIntent = new Intent(BackgroundService.ACTION_PAUSE);
            playPauseIntent = PendingIntent.getBroadcast(mService, INTENT_PLAYPAUSE, pauseIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            playPauseIcon = R.drawable.ic_pause_48dp;
        } else {
            Intent playIntent = new Intent(BackgroundService.ACTION_PLAY);
            playPauseIntent = PendingIntent.getBroadcast(mService, INTENT_PLAYPAUSE, playIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            playPauseIcon = R.drawable.ic_play_arrow_48dp;
        }
        NotificationCompat.Action playPauseAction = new NotificationCompat.Action.Builder(playPauseIcon,
                "PlayPause", playPauseIntent).build();

        // Stop action
        Intent stopIntent = new Intent(BackgroundService.ACTION_STOP);
        PendingIntent stopPendingIntent = PendingIntent.getBroadcast(mService, INTENT_STOP, stopIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Action stopActon = new NotificationCompat.Action.Builder(
                R.drawable.ic_stop_black_48dp, "Stop", stopPendingIntent).build();

        // Next song action
        Intent nextIntent = new Intent(BackgroundService.ACTION_NEXT);
        PendingIntent nextPendingIntent = PendingIntent.getBroadcast(mService, INTENT_NEXT, nextIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        NotificationCompat.Action nextAction = new NotificationCompat.Action.Builder(
                R.drawable.ic_skip_next_48dp, "Next", nextPendingIntent).build();

        // Quit action
        Intent quitIntent = new Intent(BackgroundService.ACTION_QUIT_BACKGROUND_SERVICE);
        PendingIntent quitPendingIntent = PendingIntent.getBroadcast(mService, INTENT_QUIT, quitIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        mNotificationBuilder.setDeleteIntent(quitPendingIntent);

        mNotificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
        mNotificationBuilder.setSmallIcon(R.drawable.ic_notification_24dp);
        mNotificationBuilder.addAction(prevAction);
        mNotificationBuilder.addAction(playPauseAction);
        mNotificationBuilder.addAction(stopActon);
        mNotificationBuilder.addAction(nextAction);
        NotificationCompat.MediaStyle notificationStyle = new NotificationCompat.MediaStyle();
        notificationStyle.setShowActionsInCompactView(1, 2);
        mNotificationBuilder.setStyle(notificationStyle);

        String title;
        if (track.getTrackTitle().isEmpty()) {
            title = FormatHelper.getFilenameFromPath(track.getPath());
        } else {
            title = track.getTrackTitle();
        }

        mNotificationBuilder.setContentTitle(title);

        String secondRow;

        if (!track.getTrackArtist().isEmpty() && !track.getTrackAlbum().isEmpty()) {
            secondRow = track.getTrackArtist() + mService.getString(R.string.track_item_separator)
                    + track.getTrackAlbum();
        } else if (track.getTrackArtist().isEmpty() && !track.getTrackAlbum().isEmpty()) {
            secondRow = track.getTrackAlbum();
        } else if (track.getTrackAlbum().isEmpty() && !track.getTrackArtist().isEmpty()) {
            secondRow = track.getTrackArtist();
        } else {
            secondRow = track.getPath();
        }

        // Set the media session metadata
        updateMetadata(track, state);

        mNotificationBuilder.setContentText(secondRow);

        // Remove unnecessary time info
        mNotificationBuilder.setWhen(0);

        // Cover but only if changed
        if (mNotification == null || !track.getTrackAlbum().equals(mLastTrack.getTrackAlbum())) {
            mLastTrack = track;
            mLastBitmap = null;
            mCoverLoader.getImage(mLastTrack, true);
        }

        // Only set image if an saved one is available
        if (mLastBitmap != null) {
            mNotificationBuilder.setLargeIcon(mLastBitmap);
        } else {
            /**
             * Create a dummy placeholder image for versions greater android 7 because it
             * does not automatically show the application icon anymore in mediastyle notifications.
             */
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                Drawable icon = mService.getDrawable(R.drawable.notification_placeholder_256dp);

                Bitmap iconBitmap = Bitmap.createBitmap(icon.getIntrinsicWidth(), icon.getIntrinsicHeight(),
                        Bitmap.Config.ARGB_8888);
                Canvas canvas = new Canvas(iconBitmap);
                DrawFilter filter = new PaintFlagsDrawFilter(Paint.ANTI_ALIAS_FLAG, 1);

                canvas.setDrawFilter(filter);
                icon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
                icon.setFilterBitmap(true);

                icon.draw(canvas);
                mNotificationBuilder.setLargeIcon(iconBitmap);
            } else {
                /**
                 * For older android versions set the null icon which will result in a dummy icon
                 * generated from the application icon.
                 */
                mNotificationBuilder.setLargeIcon(null);
            }
        }

        // Build the notification
        mNotification = mNotificationBuilder.build();

        // Send the notification away
        mNotificationManager.notify(NOTIFICATION_ID, mNotification);
    }
}

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

private boolean handleIntent(Intent intent, Bundle savedInstanceState) {
    boolean forceProfileListOpen = (intent.getFlags() & Intent.FLAG_ACTIVITY_CLEAR_TOP) > 0;

    if (AndroidUtils.DEBUG) {
        Log.d(TAG, "ForceOpen? " + forceProfileListOpen);
        Log.d(TAG, "IntentHandler intent = " + intent);
    }//from w ww  .j  a  va  2 s . c om

    appPreferences = VuzeRemoteApp.getAppPreferences();

    Uri data = intent.getData();
    if (data != null) {
        try {
            // check for vuze://remote//*
            String scheme = data.getScheme();
            String host = data.getHost();
            String path = data.getPath();
            if ("vuze".equals(scheme) && "remote".equals(host) && path != null && path.length() > 1) {
                String ac = path.substring(1);
                if (AndroidUtils.DEBUG) {
                    Log.d(TAG, "got ac '" + ac + "' from " + data);
                }

                intent.setData(null);
                if (ac.equals("cmd=advlogin")) {
                    DialogFragmentGenericRemoteProfile dlg = new DialogFragmentGenericRemoteProfile();
                    AndroidUtils.showDialog(dlg, getSupportFragmentManager(), "GenericRemoteProfile");
                    forceProfileListOpen = true;
                } else if (ac.length() < 100) {
                    RemoteProfile remoteProfile = new RemoteProfile("vuze", ac);
                    new RemoteUtils(this).openRemote(remoteProfile, true);
                    finish();
                    return true;
                }
            }

            // check for http[s]://remote.vuze.com/ac=*
            if (host != null && host.equals("remote.vuze.com") && data.getQueryParameter("ac") != null) {
                String ac = data.getQueryParameter("ac");
                if (AndroidUtils.DEBUG) {
                    Log.d(TAG, "got ac '" + ac + "' from " + data);
                }
                intent.setData(null);
                if (ac.length() < 100) {
                    RemoteProfile remoteProfile = new RemoteProfile("vuze", ac);
                    new RemoteUtils(this).openRemote(remoteProfile, true);
                    finish();
                    return true;
                }
            }
        } catch (Exception e) {
            if (AndroidUtils.DEBUG) {
                e.printStackTrace();
            }
        }
    }

    if (!forceProfileListOpen) {
        int numRemotes = getRemotesWithLocal().length;
        if (numRemotes == 0) {
            // New User: Send them to Login (Account Creation)
            Intent myIntent = new Intent(Intent.ACTION_VIEW, null, this, LoginActivity.class);
            myIntent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);

            startActivity(myIntent);
            finish();
            return true;
        } else if (numRemotes == 1 || intent.getData() == null) {
            try {
                RemoteProfile remoteProfile = appPreferences.getLastUsedRemote();
                if (remoteProfile != null) {
                    if (savedInstanceState == null) {
                        new RemoteUtils(this).openRemote(remoteProfile, true);
                        finish();
                        return true;
                    }
                } else {
                    Log.d(TAG, "Has Remotes, but no last remote");
                }
            } catch (Throwable t) {
                if (AndroidUtils.DEBUG) {
                    Log.e(TAG, "onCreate", t);
                }
                VuzeEasyTracker.getInstance(this).logError(t);
            }
        }
    }
    return false;
}