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.planyourexchange.fragments.result.ResultFragment.java

private void dispatchNewActivity(Class<? extends AppCompatActivity> targetActivity) {
    Intent intent = new Intent(getActivity(), targetActivity);
    intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    startActivity(intent);/*from  w  w w. j av  a 2  s.c  om*/
}

From source file:com.example.edwin.car2charge.MainActivity.java

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {

    String[] projection = { CarDatabase.C_LAT, CarDatabase.C_LONG, CarDatabase.C_ADDRESS, CarDatabase.C_LICENSE,
            CarDatabase.C_BATTERY };//from ww w.  j  a v a 2 s.  c o  m
    Cursor cursor = getContentResolver().query(
            Uri.withAppendedPath(CarDataProvider.CONTENT_URI, String.valueOf(id)), projection, null, null,
            null);
    cursor.moveToFirst();
    double lat = cursor.getDouble(0);
    double lng = cursor.getDouble(1);

    Intent i = new Intent(getApplicationContext(), DetailActivity.class);
    i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    i.putExtra("lat", lat);
    i.putExtra("long", lng);
    i.putExtra("address", cursor.getString(2));
    i.putExtra("license", cursor.getString(3));
    i.putExtra("battery", cursor.getString(4));
    startActivity(i);
    cursor.close();
}

From source file:uk.org.ngo.squeezer.framework.BaseActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if ((intent.getFlags() | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT) > 0) {
        mIsRestoredToTop = true;/*from  www . ja v a  2  s  .  c o  m*/
    }
}

From source file:es.ubiqua.atractivas.AppdiaActivity.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 w  w w.j av a 2s  .com
        return true;

    case R.id.sharemenu:
        HashMap<String, String> appdia = m_parts.get(mPager.getCurrentItem());
        new ShareIt(this, appdia.get("nombre"), appdia.get("urlclick")).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);
}

From source file:ca.mudar.snoozy.receiver.PowerConnectionReceiver.java

private void notify(Context context, boolean isConnectedPower, boolean hasVibration, boolean hasSound,
        int notifyCount) {
    final Resources res = context.getResources();

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context)
            .setSmallIcon(R.drawable.ic_notify).setContentTitle(res.getString(R.string.notify_content_title))
            .setAutoCancel(true);/*from  w  w w  .  j av a  2  s  .  c o m*/

    if (notifyCount == 1) {
        final int resContentTextSingle = (isConnectedPower ? R.string.notify_content_text_single_on
                : R.string.notify_content_text_single_off);
        mBuilder.setContentText(res.getString(resContentTextSingle));
    } else {
        mBuilder.setNumber(notifyCount).setContentText(res.getString(R.string.notify_content_text_multi));
    }

    if (hasVibration && hasSound) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_SOUND);
    } else if (hasVibration) {
        mBuilder.setDefaults(Notification.DEFAULT_VIBRATE);
    } else if (hasSound) {
        mBuilder.setDefaults(Notification.DEFAULT_SOUND);
    }

    // Creates an explicit intent for an Activity in your app
    Intent resultIntent = new Intent(context, MainActivity.class);
    final Bundle extras = new Bundle();
    extras.putBoolean(Const.IntentExtras.INCREMENT_NOTIFY_GROUP, true);
    extras.putBoolean(Const.IntentExtras.RESET_NOTIFY_NUMBER, true);
    resultIntent.putExtras(extras);
    resultIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP
            | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    mBuilder.setContentIntent(
            PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT));

    Intent receiverIntent = new Intent(context, PowerConnectionReceiver.class);
    receiverIntent.setAction(Const.IntentActions.NOTIFY_DELETE);
    PendingIntent deleteIntent = PendingIntent.getBroadcast(context, Const.RequestCodes.RESET_NOTIFY_NUMBER,
            receiverIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setDeleteIntent(deleteIntent);

    NotificationManager mNotificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    // NOTIFY_ID allows updates to the notification later on.
    mNotificationManager.notify(Const.NOTIFY_ID, mBuilder.build());
}

From source file:es.ubiqua.atractivas.GaleryActivity.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   w  w  w  .ja  va 2  s. c  om
        return true;

    case R.id.sharemenu:
        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);
}

From source file:io.github.hidroh.materialistic.SubmitActivity.java

@Synthetic
void onSubmitted(Boolean successful) {
    if (successful == null) {
        toggleControls(false);//www.jav  a 2  s.  c  om
        Toast.makeText(this, R.string.submit_failed, Toast.LENGTH_SHORT).show();
    } else if (successful) {
        Toast.makeText(this, R.string.submit_successful, Toast.LENGTH_SHORT).show();
        if (!isFinishing()) {
            Intent intent = new Intent(this, NewActivity.class);
            intent.putExtra(NewActivity.EXTRA_REFRESH, true);
            intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            startActivity(intent); // TODO should go to profile instead?
            finish();
        }
    } else if (!isFinishing()) {
        AppUtils.showLogin(this, mAlertDialogBuilder);
    }
}

From source file:ufms.br.com.ufmsapp.activity.GraficosActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Intent parentIntent = NavUtils.getParentActivityIntent(this);
        parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(parentIntent);//from www  . j  a v  a 2  s .c o m

        supportFinishAfterTransition();
        break;

    }

    return super.onOptionsItemSelected(item);

}

From source file:me.diskstation.ammon.gpsrunner.ui.DrawerActivity.java

private void issueNotification() {
    NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(this);
    //TODO: add proper icons
    nBuilder.setSmallIcon(R.drawable.ic_stat_name2);
    nBuilder.setContentTitle(getString(R.string.app_name));
    nBuilder.setContentText(getString(R.string.running));
    Intent overviewIntent = this.getIntent();
    overviewIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    PendingIntent pendingOverviewIntent = PendingIntent.getActivity(getApplicationContext(), 0, overviewIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    nBuilder.setContentIntent(pendingOverviewIntent);

    int icon = R.drawable.ic_stop_icon;
    String actionTitle = getString(R.string.stop_recording);
    Intent stopIntent = new Intent();
    stopIntent.setAction(ACTION_STOP);//  www .j  av a 2 s  .c om
    PendingIntent pendingStopIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, stopIntent, 0);
    NotificationCompat.Action action = new NotificationCompat.Action(icon, actionTitle, pendingStopIntent);
    nBuilder.addAction(action);
    nBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
    //Disable dismissability
    nBuilder.setOngoing(true);
    locServ.startForeground(1, nBuilder.build());
}

From source file:org.ff.armaconnect.WeatherActivity.java

@Override
public void run() {
    int last_update = 0;
    Weather previous_weather = null;/*  w ww  . j a va  2  s  .c  om*/
    while (mutex) {
        if (previous_weather == weather) {
            last_update++;
        } else {
            //update UI display of weather information
            if (tabHost.getCurrentTabTag().equals(getResources().getString(R.string.weather_Current))) {
                updateWeatherUI(weather);
            } else {
                updateWeatherUI(weather_forecast);
            }

            previous_weather = weather;
            last_update = 0;
        }

        if (last_update >= 8) {
            //we haven't received any new information in awhile, go back to connecting page
            Intent intent = new Intent(WeatherActivity.this, ConnectingActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            intent.putExtra("launching", "show_weather");
            startActivity(intent);
            finish(); //this will "destroy" this activity
        }

        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}