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:de.baumann.sieben.about.About_content.java

static MaterialAboutList createMaterialAboutList(final Context c) {
    MaterialAboutCard.Builder appCardBuilder = new MaterialAboutCard.Builder();

    // Add items to card

    appCardBuilder.addItem(//from  w w w . ja v  a 2  s.c  om
            new MaterialAboutTitleItem.Builder().text(R.string.app_name).icon(R.mipmap.ic_launcher).build());

    try {

        appCardBuilder.addItem(ConvenienceBuilder.createVersionActionItem(c,
                ContextCompat.getDrawable(c, R.drawable.earth2), "Version", false));

    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_changelog)
            .subText(R.string.about_changelog_summary).icon(R.drawable.format_list_bulleted)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                    c.getString(R.string.about_changelog),
                    "https://github.com/scoute-dich/Sieben/blob/master/CHANGELOG.md", true, false))
            .build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license)
            .subText(R.string.about_license_summary).icon(R.drawable.copyright)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {

                    SpannableString s;

                    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
                        s = new SpannableString(
                                Html.fromHtml(c.getString(R.string.about_text), Html.FROM_HTML_MODE_LEGACY));
                    } else {
                        //noinspection deprecation
                        s = new SpannableString(Html.fromHtml(c.getString(R.string.about_text)));
                    }

                    Linkify.addLinks(s, Linkify.WEB_URLS);

                    final AlertDialog d = new AlertDialog.Builder(c).setTitle(R.string.about_title)
                            .setMessage(s).setPositiveButton(c.getString(R.string.app_ok),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int id) {
                                            dialog.cancel();
                                        }
                                    })
                            .show();
                    d.show();
                    ((TextView) d.findViewById(android.R.id.message))
                            .setMovementMethod(LinkMovementMethod.getInstance());
                }
            }).build());

    appCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_intro)
            .subText(R.string.about_intro_summary).icon(R.drawable.information_outline)
            .setOnClickListener(new MaterialAboutActionItem.OnClickListener() {
                @Override
                public void onClick() {
                    Intent intent = new Intent(c, Activity_intro.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
                    c.startActivity(intent);
                }
            }).build());

    MaterialAboutCard.Builder authorCardBuilder = new MaterialAboutCard.Builder();
    authorCardBuilder.title(R.string.about_title_dev);

    authorCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_dev)
                    .subText(R.string.about_dev_summary).icon(R.drawable.gaukler_faun)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            c.getString(R.string.about_dev), "https://github.com/scoute-dich/", true, false))
                    .build());

    authorCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_donate)
            .subText(R.string.about_donate_summary).icon(R.drawable.coin)
            .setOnClickListener(ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse(
                    "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=NP6TGYDYP9SHY")))
            .build());

    MaterialAboutCard.Builder authorCardBuilder2 = new MaterialAboutCard.Builder();
    authorCardBuilder2.title(R.string.about_title_ext);

    authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Gilles Coulais")
            .subText(R.string.about_title_ext1).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/Djiko")))
            .build());

    authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("jeberger")
            .subText(R.string.about_title_ext1).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/jeberger")))
            .build());

    authorCardBuilder2.addItem(
            new MaterialAboutActionItem.Builder().text("Maurits Cornelis").subText(R.string.about_title_ext4)
                    .icon(R.drawable.github_circle).setOnClickListener(ConvenienceBuilder
                            .createWebsiteOnClickAction(c, Uri.parse("https://github.com/MauritsCornelis")))
                    .build());

    authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Mathias Lux")
            .subText(R.string.about_title_ext2).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/dermotte")))
            .build());

    authorCardBuilder2.addItem(new MaterialAboutActionItem.Builder().text("Neofaum")
            .subText(R.string.about_title_ext3).icon(R.drawable.github_circle)
            .setOnClickListener(
                    ConvenienceBuilder.createWebsiteOnClickAction(c, Uri.parse("https://github.com/naofum")))
            .build());

    MaterialAboutCard.Builder convenienceCardBuilder = new MaterialAboutCard.Builder();
    convenienceCardBuilder.title(R.string.about_title_libs);

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license_1_title)
            .subText(R.string.about_license_1).icon(R.drawable.earth2)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Workout images",
                    "http://almostfearless.com/the-21-minute-workout-or-7-minutes-if-youre-really-fit", true,
                    false))
            .build());

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text(R.string.about_license_2_title)
                    .subText(R.string.about_license_2).icon(R.drawable.earth2)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Whistle",
                            "http://freesound.org/people/MentalSanityOff/sounds/218318/", true, false))
                    .build());

    convenienceCardBuilder
            .addItem(new MaterialAboutActionItem.Builder().text("Android Onboarder")
                    .subText(R.string.about_license_3).icon(R.drawable.github_circle)
                    .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c,
                            "Android Onboarder", "https://github.com/chyrta/AndroidOnboarder", true, false))
                    .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material About Library")
            .subText(R.string.about_license_7).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material About Library",
                    "https://github.com/daniel-stoneuk/material-about-library", true, false))
            .build());

    convenienceCardBuilder.addItem(new MaterialAboutActionItem.Builder().text("Material Design Icons")
            .subText(R.string.about_license_8).icon(R.drawable.github_circle)
            .setOnClickListener(ConvenienceBuilder.createWebViewDialogOnClickAction(c, "Material Design Icons",
                    "https://github.com/Templarian/MaterialDesign", true, false))
            .build());

    return new MaterialAboutList(appCardBuilder.build(), authorCardBuilder.build(), authorCardBuilder2.build(),
            convenienceCardBuilder.build());
}

From source file:org.durka.hallmonitor.CoreService.java

@Override
public void onCreate() {
    Log.d(LOG_TAG + ".oC", "Core service creating");
    localCoreService = this;

    mStateManager = ((CoreApp) getApplicationContext()).getStateManager();

    Log.d(LOG_TAG + ".oC", "Register special actions");
    mStateManager.registerCoreService(this);

    mStateManager.registerCoreReceiver();

    mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);

    HandlerThread thread = new HandlerThread("ServiceStartArguments", Process.THREAD_PRIORITY_BACKGROUND);
    thread.start();//from   www  .j  a  v a  2 s  .c o  m

    // Get the HandlerThread's Looper and use it for our Handler
    mTouchCoverLooper = thread.getLooper();
    mTouchCoverHandler = new TouchCoverHandler(mTouchCoverLooper);
    lastTouchCoverRequest = mStateManager.getCoverClosed();

    try {
        startActivityAsUser = ((ContextWrapper) this).getClass().getMethod("startActivityAsUser", Intent.class,
                UserHandle.class);
        Log.d(LOG_TAG, "startActivityAsUser registred");
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }

    launchDefaultActivity = new Intent(localCoreService, DefaultActivity.class)
            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION
                    | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

    mUserHandle = android.os.Process.myUserHandle();
}

From source file:ua.mkh.settings.full.AbstractGetNameTask.java

/**
 * Contacts the user info server to get the profile of the user and extracts
 * the first name of the user from the profile. In order to authenticate
 * with the user info server the method first fetches an access token from
 * Google Play services./*w  w w . j a  v  a 2  s  .c  o m*/
 * @return 
 * @return 
 * 
 * @throws IOException
 *             if communication with user info server failed.
 * @throws JSONException
 *             if the response from the server could not be parsed.
 */
private void fetchNameFromProfileServer() throws IOException, JSONException {
    String token = fetchToken();
    URL url = new URL("https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + token);
    HttpURLConnection con = (HttpURLConnection) url.openConnection();
    int sc = con.getResponseCode();
    if (sc == 200) {
        InputStream is = con.getInputStream();
        GOOGLE_USER_DATA = readResponse(is);
        is.close();

        Intent intent = new Intent(mActivity, ActivityiCloud.class);
        intent.putExtra("email_id", mEmail);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        mActivity.startActivity(intent);

        return;
    } else if (sc == 401) {
        GoogleAuthUtil.invalidateToken(mActivity, token);
        onError("Server auth error, please try again.", null);
        //Toast.makeText(mActivity, "Please try again", Toast.LENGTH_SHORT).show();
        //mActivity.finish();
        return;
    } else {
        onError("Server returned the following error code: " + sc, null);
        return;
    }
}

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

public void onClick(View view) {
    int id = view.getId();
    if (id == R.id.switch_list) {
        Intent intent = new Intent(POIsMapsforgeActivity.this,
                org.wheelmap.android.activity.POIsListActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);//from w w w  . j  a  v a  2s . c o m
        overridePendingTransition(0, 0);
    }
}

From source file:info.balthaus.geologrenewed.app.service.BackgroundService.java

@SuppressLint("NewApi")
@Override//from w  w w.j  av  a2  s  .c o  m
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:de.dreier.mytargets.utils.IntentWrapper.java

public IntentWrapper noAnimation() {
    intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_NO_ANIMATION);
    animate = false;
    return this;
}

From source file:azad.hallaji.farzad.com.masirezendegi.ExplainMoshaver.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_explain_moshaver);
    Fabric.with(this, new Crashlytics());

    alagestarmoshaver = (ImageView) findViewById(R.id.alagestarmoshaver);

    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            placeid = "";
        } else {/*from  w  ww.  j  a  va 2 s  .  co m*/
            placeid = extras.getString("placeid");
        }
    } else {
        placeid = (String) savedInstanceState.getSerializable("placeid");
    }

    ImageView imageView1 = (ImageView) findViewById(R.id.backButton);
    imageView1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(ExplainMoshaver.this, PageMoshaverin.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
            startActivity(intent);
        }
    });

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);
    ImageView imageView = (ImageView) findViewById(R.id.menuButton);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawer.openDrawer(Gravity.END);
        }
    });

    if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {
        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(true);
        nav_Menu.findItem(R.id.nav_login).setVisible(false);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(true);
    } else {
        Menu nav_Menu = navigationView.getMenu();
        nav_Menu.findItem(R.id.nav_marakez).setVisible(true);
        nav_Menu.findItem(R.id.nav_profile).setVisible(false);
        nav_Menu.findItem(R.id.nav_login).setVisible(true);
        nav_Menu.findItem(R.id.nav_moshaverin).setVisible(true);
        nav_Menu.findItem(R.id.nav_porseshha).setVisible(true);
        nav_Menu.findItem(R.id.nav_logout).setVisible(false);
    }

    userimg = (ImageView) findViewById(R.id.adviser_image);
    name_moshaver_textview = (TextView) findViewById(R.id.name_moshaver_textview);
    //taxassose_moshaver_textview =(TextView) findViewById(R.id.taxassose_moshaver_textview);
    code_moshaver_textview = (TextView) findViewById(R.id.code_moshaver_textview);

    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            adviseridm = "0";
        } else {
            adviseridm = extras.getString("adviserid");
        }
    } else {
        adviseridm = (String) savedInstanceState.getSerializable("adviserid");
    }

    //Toast.makeText(getApplicationContext(), "+"+adviseridm+"+", Toast.LENGTH_LONG).show();

    if (isOnline()) {
        //requestData();

        postgetData();
        //Log.i("Lieseesene",License);

        ImageView imageView2 = (ImageView) findViewById(R.id.adviser_about_img);
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //requestDataa();

                if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {

                    Intent intent3 = new Intent(ExplainMoshaver.this, PageRezerv.class);
                    intent3.putExtra("adviseridm", adviseridm);
                    intent3.putExtra("placeid", placeid);
                    intent3.putExtra("namemoshaver", namemoshaver);

                    startActivity(intent3);

                } else {
                    Toast.makeText(getApplicationContext(), "    ",
                            Toast.LENGTH_LONG).show();
                }

            }
        });

        //
        // final ImageView alagestarmarkaz = (ImageView)findViewById(R.id.alagestarmarkaz);

        alagestarmoshaver.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcpsdcpsdcpsdc"+alagestarmarkaz.getResources());

                if (GlobalVar.getUserType().equals("adviser") || GlobalVar.getUserType().equals("user")) {

                    setAlage();
                    //Log.i("sxascsdcpsdcpsdcpsdc","[sxascsdcp2sdcpsdcpsdc"+hanyayo);

                } else {
                    Toast.makeText(getApplicationContext(), "    ",
                            Toast.LENGTH_LONG).show();
                }
            }
        });

        ImageView adviser_reserve_img = (ImageView) findViewById(R.id.adviser_reserve_img);
        adviser_reserve_img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final LinearLayout darbareyehuseyin = (LinearLayout) findViewById(R.id.darbareyehuseyin);
                darbareyehuseyin.setVisibility(View.VISIBLE);
                TextView textTagsHusseyin = (TextView) findViewById(R.id.textTagsHusseyin);
                try {
                    textTagsHusseyin.setText(Tagggggggs);
                    ImageView closeafzundanejavab = (ImageView) findViewById(R.id.closeinvisibleimag);
                    closeafzundanejavab.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            darbareyehuseyin.setVisibility(View.GONE);
                        }
                    });

                } catch (Exception e) {
                    textTagsHusseyin.setText("");
                }

            }
        });

    } else {
        Toast.makeText(getApplicationContext(), "Network isn't available", Toast.LENGTH_LONG).show();
    }
}

From source file:org.gateshipone.odyssey.playbackservice.managers.OdysseyNotificationManager.java

public void updateNotification(TrackModel track, PlaybackService.PLAYSTATE state,
        MediaSessionCompat.Token mediaSessionToken) {
    if (track != null) {
        mNotificationBuilder = new NotificationCompat.Builder(mContext);

        // Open application intent
        Intent contentIntent = new Intent(mContext, OdysseyMainActivity.class);
        contentIntent.putExtra(OdysseyMainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW,
                OdysseyMainActivity.MAINACTIVITY_INTENT_EXTRA_REQUESTEDVIEW_NOWPLAYINGVIEW);
        contentIntent.addFlags(// ww  w .  ja  va 2  s .c  o  m
                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(mContext, NOTIFICATION_INTENT_OPENGUI,
                contentIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        mNotificationBuilder.setContentIntent(contentPendingIntent);

        // Set pendingintents
        // Previous song action
        Intent prevIntent = new Intent(PlaybackService.ACTION_PREVIOUS);
        PendingIntent prevPendingIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_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 == PlaybackService.PLAYSTATE.PLAYING) {
            Intent pauseIntent = new Intent(PlaybackService.ACTION_PAUSE);
            playPauseIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_INTENT_PLAYPAUSE, pauseIntent,
                    PendingIntent.FLAG_UPDATE_CURRENT);
            playPauseIcon = R.drawable.ic_pause_48dp;
        } else {
            Intent playIntent = new Intent(PlaybackService.ACTION_PLAY);
            playPauseIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_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();

        // Next song action
        Intent nextIntent = new Intent(PlaybackService.ACTION_NEXT);
        PendingIntent nextPendingIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_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(PlaybackService.ACTION_QUIT);
        PendingIntent quitPendingIntent = PendingIntent.getBroadcast(mContext, NOTIFICATION_INTENT_QUIT,
                quitIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        mNotificationBuilder.setDeleteIntent(quitPendingIntent);

        mNotificationBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
        mNotificationBuilder.setSmallIcon(R.drawable.odyssey_notification);
        mNotificationBuilder.addAction(prevAction);
        mNotificationBuilder.addAction(playPauseAction);
        mNotificationBuilder.addAction(nextAction);
        NotificationCompat.MediaStyle notificationStyle = new NotificationCompat.MediaStyle();
        notificationStyle.setShowActionsInCompactView(1, 2);
        notificationStyle.setMediaSession(mediaSessionToken);
        mNotificationBuilder.setStyle(notificationStyle);
        mNotificationBuilder.setContentTitle(track.getTrackName());
        mNotificationBuilder.setContentText(track.getTrackArtistName());

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

        // Cover but only if changed
        if (mLastTrack == null || !track.getTrackAlbumKey().equals(mLastTrack.getTrackAlbumKey())) {
            mLastTrack = track;
            mLastBitmap = null;
        }

        // 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 = mContext.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();

        // Check if run from service and check if playing or pause.
        // Pause notification should be dismissible.
        if (mContext instanceof Service) {
            if (state == PlaybackService.PLAYSTATE.PLAYING) {
                ((Service) mContext).startForeground(NOTIFICATION_ID, mNotification);
            } else {
                ((Service) mContext).stopForeground(false);
            }
        }

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

}

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

public static void switchToActivity(Activity activity, Class to, boolean finishActivity) {
    Intent intent = new Intent(activity, to);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    activity.startActivity(intent);//from www .j  a  va 2s . co m
    if (finishActivity) {
        activity.finish();
    }
}

From source file:com.xiaoxin.apktools.app.BaseActivity.java

/**
 * ??Activity?Activity/*from  ww w .  j  av  a  2  s  .  c om*/
 */
public void reload() {
    Intent intent = getIntent();
    overridePendingTransition(0, 0);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
    finish();
    overridePendingTransition(0, 0);
    startActivity(intent);
}