Example usage for android.content Intent FLAG_ACTIVITY_REORDER_TO_FRONT

List of usage examples for android.content Intent FLAG_ACTIVITY_REORDER_TO_FRONT

Introduction

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

Prototype

int FLAG_ACTIVITY_REORDER_TO_FRONT

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

Click Source Link

Document

If set in an Intent passed to Context#startActivity Context.startActivity() , this flag will cause the launched activity to be brought to the front of its task's history stack if it is already running.

Usage

From source file:com.hro.museapp.map.ClusteringMapActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.list_view:
        Intent i = new Intent(getApplicationContext(), AllPlacesActivity.class);
        i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(i);// w ww  .  j  a  v  a 2  s .c  o m

        break;

    case android.R.id.home:
        // app icon in action bar clicked; go home
        Intent intentHome = new Intent(this, Start.class);
        intentHome.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intentHome);
        break;

    default:
        break;
    }

    return true;
}

From source file:com.webshrub.greetings.eid.androidapp.FestivityHomeActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_rate_us:
        String marketUrl = "market://details?id=com.webshrub.greetings.eid.androidapp";
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(marketUrl)));
        return true;
    case R.id.menu_share_on_facebook:
        String facebookUrl = "https://www.facebook.com/dialog/feed?app_id=300503886742748&link=https://www.facebook.com/pages/Festivity-Holi/474603645926400&picture=http://pure-cove-2261.herokuapp.com/images/logo_64.png&name=Festivity%20Holi&caption=Festivity%20Holi&description=Festivity%20Holi&redirect_uri=http://pure-cove-2261.herokuapp.com/";
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(facebookUrl)));
        return true;
    case R.id.menu_share_on_twitter:
        String twitterUrl = "https://twitter.com/intent/tweet?text=Friends%2C%20I%20am%20using%20%23dndmanager%20to%20block%20pesky%20Calls%2FSMS.%20Download%20it%20http%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.webshrub.moonwalker.androidapp";
        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(twitterUrl)));
        return true;
    case R.id.menu_settings:
        Intent preferenceIntent = new Intent(this, FestivityPreferenceActivity.class);
        preferenceIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(preferenceIntent);
        return true;
    case R.id.menu_about:
        Intent aboutIntent = new Intent(this, FestivityAboutActivity.class);
        startActivity(aboutIntent);/*from  www.  java2 s .c o  m*/
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

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

@Override
public void onShowLargeMapAt(GeoPoint point) {
    Intent intent = new Intent(this, MainSinglePaneActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    intent.putExtra(Extra.SELECTED_TAB, MyTabListener.TAB_MAP);
    intent.putExtra(Extra.CENTER_MAP, true);
    intent.putExtra(Extra.LATITUDE, point.getLatitude());
    intent.putExtra(Extra.LONGITUDE, point.getLongitude());
    intent.putExtra(Extra.REQUEST, true);
    startActivity(intent);/* www.  j ava 2s  . co m*/
}

From source file:com.melbournestore.activities.PlateActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // This is called when the Home (Up) button is pressed in the action
        // bar./* w  ww.j a  v  a  2  s . co m*/
        // Create a simple intent that starts the hierarchical parent
        // activity and
        // use NavUtils in the Support Package to ensure proper handling of
        // Up.
        Intent upIntent = NavUtils.getParentActivityIntent(this);
        upIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(upIntent);
        finish();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.marianhello.bgloc.LocationService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    log.info("Received start startId: {} intent: {}", startId, intent);

    if (provider != null) {
        provider.onDestroy();/*from   w ww.j  a  v a2s .  c o  m*/
    }

    if (intent == null) {
        //service has been probably restarted so we need to load config from db
        ConfigurationDAO dao = DAOFactory.createConfigurationDAO(this);
        try {
            config = dao.retrieveConfiguration();
        } catch (JSONException e) {
            log.error("Config exception: {}", e.getMessage());
            config = new Config(); //using default config
        }
    } else {
        if (intent.hasExtra("config")) {
            config = intent.getParcelableExtra("config");
        } else {
            config = new Config(); //using default config
        }
    }

    log.debug("Will start service with: {}", config.toString());

    LocationProviderFactory spf = new LocationProviderFactory(this);
    provider = spf.getInstance(config.getLocationProvider());

    if (config.getStartForeground()) {
        // Build a Notification required for running service in foreground.
        NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
        builder.setContentTitle(config.getNotificationTitle());
        builder.setContentText(config.getNotificationText());
        if (config.getSmallNotificationIcon() != null) {
            builder.setSmallIcon(getDrawableResource(config.getSmallNotificationIcon()));
        } else {
            builder.setSmallIcon(android.R.drawable.ic_menu_mylocation);
        }
        if (config.getLargeNotificationIcon() != null) {
            builder.setLargeIcon(BitmapFactory.decodeResource(getApplication().getResources(),
                    getDrawableResource(config.getLargeNotificationIcon())));
        }
        if (config.getNotificationIconColor() != null) {
            builder.setColor(this.parseNotificationIconColor(config.getNotificationIconColor()));
        }

        // Add an onclick handler to the notification
        Context context = getApplicationContext();
        String packageName = context.getPackageName();
        Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);
        launchIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launchIntent,
                PendingIntent.FLAG_CANCEL_CURRENT);
        builder.setContentIntent(contentIntent);

        Notification notification = builder.build();
        notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE
                | Notification.FLAG_NO_CLEAR;
        startForeground(startId, notification);
    }

    provider.startRecording();

    //We want this service to continue running until it is explicitly stopped
    return START_STICKY;
}

From source file:com.shipdream.lib.android.mvc.view.BaseTestCase.java

protected void bringBack() {
    Intent i = new Intent(activity.getApplicationContext(), activity.getClass());
    i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    activity.startActivity(i);/* w  ww .j a v  a2  s  . c  o  m*/
}

From source file:es.eucm.eadandroid.homeapp.WorkspaceActivity.java

/**
 * Static method for creating intents to start other activities
 *///from   w ww .j  a v  a  2  s  .  c  om
public static Intent createIntent(Context context, Class<?> c) {
    Intent i = new Intent(context, c);
    i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    return i;
}

From source file:com.callrecorder.android.RecordService.java

private void startService() {
    if (!onForeground) {
        Log.d(Constants.TAG, "RecordService startService");
        Intent intent = new Intent(this, MainActivity.class);
        // intent.setAction(Intent.ACTION_VIEW);
        // intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        PendingIntent pendingIntent = PendingIntent.getActivity(getBaseContext(), 0, intent, 0);

        Notification notification = new NotificationCompat.Builder(getBaseContext())
                .setContentTitle(this.getString(R.string.notification_title))
                .setTicker(this.getString(R.string.notification_ticker))
                .setContentText(this.getString(R.string.notification_text)).setSmallIcon(R.drawable.ic_launcher)
                .setContentIntent(pendingIntent).setOngoing(true).getNotification();

        notification.flags = Notification.FLAG_NO_CLEAR;

        startForeground(1337, notification);
        onForeground = true;// www. j av  a2s  .c  om
    }
}

From source file:com.cssweb.android.common.FairyUI.java

public static Intent genIntent(int paramInt1, int paramInt2, String paramString2, String paramString3,
        Context paramContext) {//  www  .j  ava 2  s .  c  om
    Intent localIntent = new Intent();
    if (paramInt1 == Global.NJZQ_WTJY) {
        localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        // ?
        switch (paramInt2) {
        case 0:
            localIntent.setClass(paramContext, AccountManage.class);
            break;
        case 1:
            localIntent.putExtra("type", 0);
            localIntent.putExtra("bsname", "");
            localIntent.putExtra("stkcode", paramString2);
            localIntent.setClass(paramContext, StockTrading.class);
            break;
        case 2:
            localIntent.putExtra("type", 1);
            localIntent.putExtra("bsname", "?");
            localIntent.putExtra("stkcode", paramString2);
            localIntent.setClass(paramContext, StockTrading.class);
            break;
        case 3:
            localIntent.setClass(paramContext, StockCancel.class);
            break;
        case 4:
            localIntent.putExtra("menu_id", Global.NJZQ_WTJY_FIVE);
            localIntent.setClass(paramContext, BankActivity.class);
            break;
        case 5:
            localIntent.putExtra("type", Global.QUERY_STOCK_DRWT);
            localIntent.setClass(paramContext, TodayEntrust.class);
            break;
        case 6:
            localIntent.putExtra("type", Global.QUERY_STOCK_DRCJ);
            localIntent.setClass(paramContext, TodayDeal.class);
            break;
        case 7:
            localIntent.setClass(paramContext, GetPosition.class);
            break;
        case 8:
            localIntent.setClass(paramContext, AssetQuery.class);
            break;
        }
    } else if (paramInt1 == Global.NJZQ_WTJY_TWO) {
        localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        // ?
        switch (paramInt2) {
        case 0:
            localIntent.putExtra("menuid", Global.OPEN_GP);
            localIntent.putExtra("menudetail", Global.QUERY_STOCK_DZD);
            localIntent.setClass(paramContext, DateRange.class);
            break;
        case 1:
            localIntent.putExtra("menuid", Global.OPEN_GP);
            localIntent.putExtra("menudetail", Global.QUERY_STOCK_LSWT);
            localIntent.setClass(paramContext, DateRange.class);
            break;
        case 2:
            localIntent.putExtra("menu_id", Global.NJZQ_WTJY_GP_THREE);
            localIntent.setClass(paramContext, FundActivity.class);
            break;
        case 3:
            localIntent.putExtra("menu_id", Global.NJZQ_WTJY_GP_ONE);
            localIntent.setClass(paramContext, CnjjActivity.class);
            break;
        case 4:
            localIntent.putExtra("pos", Global.NJZQ_WTJY_SZLC);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:
            localIntent.putExtra("pos", Global.NJZQ_WTJY_RZRQ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 6:
            localIntent.putExtra("menuid", Global.OPEN_GP);
            localIntent.putExtra("menudetail", Global.QUERY_NEW_STOCK_MATCH);
            localIntent.setClass(paramContext, DateRange.class);
            break;
        case 7:
            localIntent.setClass(paramContext, ModifyPassword.class);
            break;
        case 8:
            localIntent.setClass(paramContext, ShareholderList.class);
            break;
        }
    } else if (paramInt1 == Global.NJZQ_WTJY_THREE) {
        localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        switch (paramInt2) {
        case 0:
            localIntent.setClass(paramContext, ModifyContactInfo.class);
            break;
        }
    } else if (paramInt1 == Global.NJZQ_HQBJ) {
        if (!isNetworkErrorGoInActivity(paramContext)) {
            //            localIntent.putExtra("restart", 2);
            //            localIntent.setClass(paramContext, RestartDialog.class);
            loadAllStock(paramInt1, paramInt2, paramString2, paramString3, paramContext);
            localIntent = null;
        } else {
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            switch (paramInt2) {
            case 0:
                localIntent = genIsLoginIntent(Global.NJZQ_HQBJ_HQYJ, Global.NJZQ_HQBJ_HQYJ, paramContext);
                break;
            case 1:
                // 
                // localIntent.putExtra("requestType", 1);
                // localIntent.setClass(paramContext, PersonalStock.class);
                if (TradeUser.getInstance().getLoginType() == 3) {
                    localIntent.putExtra("requestType", 1);
                    localIntent.setClass(paramContext, PersonalStock.class);
                } else
                    localIntent = genIsLoginIntent(Global.QUOTE_USERSTK, Global.QUOTE_USERSTK, paramContext);
                break;
            case 2:
                localIntent.putExtra("requestType", 2);
                localIntent.setClass(paramContext, DaPan.class);
                break;
            case 3:
                localIntent.putExtra("requestType", 0);
                localIntent.setClass(paramContext, PaiMing.class);
                break;
            case 4:
                localIntent.putExtra("menuid", Global.QUOTE_FENSHI);
                localIntent.setClass(paramContext, QueryStock.class);
                break;
            case 5:
                localIntent.putExtra("requestType", 2);
                localIntent.setClass(paramContext, FenLei.class);
                break;
            case 6:
                localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_EGHT);
                localIntent.setClass(paramContext, OTCFundActivity.class);
                break;
            case 7:
                localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_FIVE);
                localIntent.setClass(paramContext, GlobalMarketActivity.class);
                break;
            case 8:
                localIntent.putExtra("menu_id", Global.NJZQ_HQBJ_QHHQ);
                localIntent.setClass(paramContext, QHHQActivity.class);
                break;
            }
        }
    } else if (paramInt1 == Global.NJZQ_ZXHD) {
        switch (paramInt2) {
        case 0:// 
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_ZJJP);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1://
            localIntent = genIsLoginIntent(Global.NJZQ_ZXHD_TZGW, Global.NJZQ_ZXHD_TZGW, paramContext);
            break;
        case 2://??
            if (TradeUser.getInstance().getLoginType() == 3) {
                localIntent.putExtra("pos", Global.NJZQ_ZXHD_KHJL);
                localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                localIntent.setClass(paramContext, WebViewDisplay.class);
            } else
                localIntent = genIsLoginIntent(Global.NJZQ_ZXHD_KHJL, Global.NJZQ_ZXHD_KHJL, paramContext);
            break;
        case 3:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_ZXKF);// ?
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_KFRX);// ?
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:// 
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_GNLY);// 
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 6:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            localIntent.putExtra("pos", Global.NJZQ_ZXHD_CJWT);// ?
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 7:
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            localIntent.putExtra("menu_id", Global.NJZQ_ZXHD_EGHT);// 
            localIntent.setClass(paramContext, VistualTrade.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_NZFC) {// ??
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0:
            localIntent.putExtra("pos", Global.NJZQ_NZFC_NZDT);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_NZFC_ZJNZ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_NZFC_JYH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_NZBD) {// ???
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            localIntent.putExtra("menu_id", Global.NJZQ_NZBD_JXZQC);
            localIntent.setClass(paramContext, JxgpcActivity.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_NZBD_TZZH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_NZBD_ZQYJ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 3:
            localIntent.putExtra("pos", Global.NJZQ_NZBD_QHYJ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:// ?
            localIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            localIntent.putExtra("menu_id", Global.NJZQ_NZBD_CFPD);
            localIntent.setClass(paramContext, CfpdActivity.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_ZXLP) {// 
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_CPBD);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_YWZJ);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_PMHH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 3:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_TGLC);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:
            // localIntent.putExtra("pos", Global.NJZQ_ZXLP_ZJLX);
            // localIntent.setClass(paramContext, WebViewDisplay.class);
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_ZJLX);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:
            localIntent.putExtra("pos", Global.NJZQ_ZXLP_GG);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        default:
            localIntent = null;
            break;
        }
    } else if (paramInt1 == Global.NJZQ_JFSC) {// ?
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        // localIntent = genIsLoginIntent(Global.NJZQ_JFSC,
        // Global.NJZQ_JFSC, paramContext);
        localIntent.putExtra("pos", Global.NJZQ_JFSC);
        localIntent.setClass(paramContext, WebViewDisplay.class);
    } else if (paramInt1 == Global.NJZQ_ZSYYT) {// ?
        localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        switch (paramInt2) {
        case 0://
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YYKH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 1:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YYTGG);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 2:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YYWD);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 3:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_YWZX);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 4:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_TZZJY);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        case 5:
            localIntent.putExtra("pos", Global.NJZQ_ZSYYT_TJKH);
            localIntent.setClass(paramContext, WebViewDisplay.class);
            break;
        default:
            localIntent = null;
            break;
        }
    }
    return localIntent;
}

From source file:es.ubiqua.atractivas.ArticleActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // Navigate "up" the demo structure to the launchpad activity.
        // See http://developer.android.com/design/patterns/navigation.html for more.
        //NavUtils.navigateUpTo( this, new Intent( this, MainActivity.class ) );
        onBackPressed();//from   www .j  a  v a  2s  .  c  o  m
        return true;

    case R.id.sharemenu:
        Rss rss = m_parts.get(mPager.getCurrentItem());
        new ShareIt(this, rss.getTitle(), rss.getLink()).share();
        invalidateOptionsMenu();
        return true;

    case R.id.searchmenu:
        if (fromSearch) {
            onBackPressed();
            return true;
        }
        finish();
        ApplicationApp.launchSearch = true;
        Intent i = new Intent(this, MainActivity.class);
        i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        //            i.setAction(Intent.ACTION_MAIN);
        //            i.addCategory(Intent.CATEGORY_LAUNCHER);
        startActivity(i);
        return true;
    }

    return super.onOptionsItemSelected(item);
}