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.android.gcm.client.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    final SharedPreferences prefs = getSharedPreferences("gcmclient", Context.MODE_PRIVATE);
    pushpak = prefs.getString("push_pak", "");
    pushact = prefs.getString("push_act", "");
    final boolean pushon = prefs.getBoolean("push_on", true);
    final boolean pushnotif = prefs.getBoolean("push_notification", true);

    if (pushnotif) {
        final String notifact = prefs.getString("notification_act", "");
        Bundle extras = intent.getExtras();
        GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
        // The getMessageType() intent parameter must be the intent you received
        // in your BroadcastReceiver.
        String messageType = gcm.getMessageType(intent);

        // Send a notification.
        if (!extras.isEmpty()) { // has effect of unparcelling Bundle
            /*//from   ww  w . j  a va 2s.  c  om
             * Filter messages based on message type. Since it is likely that GCM will be
             * extended in the future with new message types, just ignore any message types you're
             * not interested in, or that you don't recognize.
             */
            if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
                sendNotification(getString(R.string.send_error) + ": " + extras.toString(), notifact);
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
                sendNotification(getString(R.string.deleted) + ": " + extras.toString(), notifact);
                // If it's a regular GCM message, do some work.
            } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
                // Post notification of received message.
                sendNotification(
                        getString(R.string.received, extras.getString("name"), extras.getString("num")),
                        notifact);
                Log.i(TAG, "Received: " + extras.toString());
            }
        }
    }

    // End if push is not enabled.
    if (!pushon) {
        // Release the wake lock provided by the WakefulBroadcastReceiver.
        GcmBroadcastReceiver.completeWakefulIntent(intent);
        return;
    }

    final boolean fullwake = prefs.getBoolean("full_wake", false);
    final boolean endoff = prefs.getBoolean("end_off", true);

    // Manage the screen.
    PowerManager mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock mWakeLock = mPowerManager
            .newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
    boolean misScreenOn = mPowerManager.isScreenOn();
    int mScreenTimeout = 0;
    if (!misScreenOn) {
        if (endoff) {
            // Change the screen timeout setting.
            mScreenTimeout = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT,
                    0);
            if (mScreenTimeout != 0) {
                Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, 3000);
            }
        }
        // Full wake lock
        if (fullwake) {
            mWakeLock.acquire();
        }
    }

    // Start the activity.
    try {
        startActivity(getPushactIntent(Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_ACTIVITY_NO_ANIMATION
                | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS));
        // Wait to register.
        Thread.sleep(REGISTER_DURATION);
    } catch (android.content.ActivityNotFoundException e) {
        RING_DURATION = 0;
        Log.i(TAG, "Activity not started");
    } catch (InterruptedException e) {
    }

    // Release the wake lock.
    if (!misScreenOn && fullwake) {
        mWakeLock.release();
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);

    // Restore the screen timeout setting.
    if (endoff && mScreenTimeout != 0) {
        try {
            Thread.sleep(RING_DURATION);
        } catch (InterruptedException e) {
        }
        Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, mScreenTimeout);
    }
}

From source file:no.android.proxime.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);/* w w  w. j av a2  s .co  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);
            startActivity(action);
            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:owne.android.envmonitor.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);//from w  w  w  .  j av  a2 s.c  om
        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);
            startActivity(action);
            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);
            }
        });
        container.addView(item);
    }
}

From source file:com.gudong.appkit.ui.activity.BaseActivity.java

/**
 * ??Activity?Activity//from   www .  ja v a2s.co m
 */
public void reload() {
    Intent intent = getIntent();
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();
    overridePendingTransition(0, 0);
    startActivity(intent);

    //      recreate();
}

From source file:com.buddi.client.dfu.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);//  w  w w .j a v  a 2  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.duy.pascal.ui.activities.SplashScreenActivity.java

private void handleRunProgram(Intent data) {
    Intent runIntent = new Intent(this, ExecuteActivity.class);
    runIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    Serializable file = data.getSerializableExtra(CompileManager.EXTRA_FILE);
    runIntent.putExtra(CompileManager.EXTRA_FILE, file);
    overridePendingTransition(0, 0);/*from   w  w w  .j a v  a  2s.  co m*/
    startActivity(runIntent);
    finish();
}

From source file:in.rab.ordboken.Ordboken.java

static void startWordActivity(Activity activity, String word, String url) {
    Intent intent = new Intent(activity, WordActivity.class);

    intent.putExtra("title", word);
    intent.putExtra("url", url);

    intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    activity.startActivity(intent);// ww w. j  a v  a2s.c om
}

From source file:com.meetingninja.csse.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SessionManager.getInstance().init(MainActivity.this);
    session = SessionManager.getInstance();

    // Check if logged in
    if (!session.isLoggedIn()) {
        Log.v(TAG, "User is not logged in");
        Intent login = new Intent(this, LoginActivity.class);
        // Bring login to front
        login.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        // User cannot go back to this activity
        // login.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        // Show no animation when launching login page
        login.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(login);//from  w w  w  . j a v a  2  s . co m
        finish(); // close main activity
    } else { // Else continue
        Log.v(TAG, "UserID " + session.getUserID() + " is logged in");
        setContentView(R.layout.activity_main);
        setupActionBar();
        setupViews();

        // on first time display view for first nav item
        selectItem(session.getPage());

        // Check to see if data has been cached in the local database
        if (savedInstanceState != null) {
            isDataCached = savedInstanceState.getBoolean(KEY_SQL_CACHE, false);
        }
        if (!isDataCached && session.needsSync()) {
            ApplicationController.getInstance().loadUsers();
            isDataCached = true;
            session.setSynced();
        }

        // Track the usage of the application with Parse SDK
        ParseAnalytics.trackAppOpened(getIntent());
        ParseUser parseUser = ParseUser.getCurrentUser();
        if (parseUser != null) {
            ParseInstallation installation = ParseInstallation.getCurrentInstallation();
            installation.put("user", parseUser);
            installation.put("userId", parseUser.getObjectId());
            installation.saveEventually();
        }
    }

}

From source file:com.bluros.music.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  ww  .  j a v a 2s. 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);

    if (MusicUtils.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.evandroid.musica.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);
    }/*from w w w  . j  a  v  a2s  . co  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);

    if (TimberUtils.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);
    }
}