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:ufms.br.com.ufmsapp.activity.DetalhesEventoActivity.java

public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Intent parentIntent = NavUtils.getParentActivityIntent(this);
        //parentIntent.putExtra("NAV_VALUE", getIntent().getIntExtra("NAV_UP", -1));
        parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP
                | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(parentIntent);/*w w w. j ava 2  s  .  c  om*/

        supportFinishAfterTransition();

        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.arcusapp.soundbox.fragment.SongsListFragment.java

private void addRandomButton() {
    // create the button
    Button myButton = new Button(getActivity());
    myButton.setId(19);/*from   ww  w .j av  a  2 s.co m*/
    myButton.setText(this.getString(R.string.LabelPlaySongsRandom));
    myButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    myButton.setCompoundDrawablesWithIntrinsicBounds(null, null,
            getResources().getDrawable(R.drawable.icon_random_shuffled), null);
    myButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            //start the playActivity
            Intent playActivityIntent = new Intent();
            playActivityIntent.setAction(SoundBoxApplication.ACTION_MAIN_ACTIVITY);
            playActivityIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            getActivity().startActivity(playActivityIntent);

            //call the service to play new songs
            Intent serviceIntent = new Intent(MediaPlayerService.PLAY_NEW_SONGS, null,
                    SoundBoxApplication.getContext(), MediaPlayerService.class);

            Bundle b = new Bundle();
            Collections.shuffle(songsIDs);
            b.putStringArrayList(BundleExtra.SONGS_ID_LIST, new ArrayList<String>(songsIDs));
            b.putString(BundleExtra.CURRENT_ID, BundleExtra.DefaultValues.DEFAULT_ID);

            serviceIntent.putExtras(b);
            getActivity().startService(serviceIntent);
        }
    });

    // add the button to the header of the list
    myListView.addHeaderView(myButton);
}

From source file:com.miljin.setminder.TimerService.java

public void broadcastTime(long inputMillis) {
    //(re)start main activity in preparation to receive "timer done" intent
    //main activity will come to foreground whether it was paused or destroyed
    //putting this block in broadcastDone() will (re)start the activity BUT the broadcast...
    // ...will NOT get received, therefore finishTimer() will not get called (tested)
    if (inputMillis < 500) {
        Intent intent = new Intent(getApplicationContext(), MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intent);//from  ww w .j ava2s . c  om
    }

    Intent tickIntent = new Intent(MainActivity.ACTION_RECEIVE_TIMER_TICK);
    tickIntent.putExtra(EXTRA_TIMER_TICK, inputMillis);
    sendBroadcast(tickIntent);
}

From source file:uk.org.ngo.squeezer.itemlist.AlarmsActivity.java

public static void show(Activity context) {
    final Intent intent = new Intent(context, AlarmsActivity.class)
            .addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    context.startActivity(intent);//  w  w w  .j a  va  2  s  .  com
}

From source file:com.tenforwardconsulting.cordova.bgloc.AbstractLocationService.java

/**
 * Adds an onclick handler to the notification
 *//*from   w w w.j av  a2 s.  c  o m*/
protected NotificationCompat.Builder setClickEvent(NotificationCompat.Builder builder) {
    int requestCode = new Random().nextInt();
    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, requestCode, launchIntent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    return builder.setContentIntent(contentIntent);
}

From source file:cz.muni.fi.japanesedictionary.main.FavoriteActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    mDrawerLayout.closeDrawer(mDrawerList);
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//  w w w  .j a va 2 s. c o  m
    switch (item.getItemId()) {
    case R.id.settings:
        Log.i(LOG_TAG, "Lauching preference Activity");
        Intent intentSetting = new Intent(this.getApplicationContext(),
                cz.muni.fi.japanesedictionary.main.MyPreferencesActivity.class);
        intentSetting.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intentSetting);
        return true;
    case R.id.about:
        Log.i(LOG_TAG, "Lauching About Activity");
        Intent intentAbout = new Intent(this.getApplicationContext(),
                cz.muni.fi.japanesedictionary.main.AboutActivity.class);
        intentAbout.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intentAbout);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }

}

From source file:com.bonsai.wallet32.BaseWalletActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle presses on the action bar items
    Intent intent;//  ww w .j ava 2s .c  o m
    switch (item.getItemId()) {
    case R.id.action_settings:
        intent = new Intent(this, SettingsActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intent);
        return true;
    case R.id.action_view_seed:
        if (mApp.passcodeFreshlyEntered()) {
            intent = new Intent(this, ViewSeedActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        } else {
            intent = new Intent(this, PasscodeActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("action", "viewseed");
            intent.putExtras(bundle);
        }
        startActivity(intent);
        return true;
    case R.id.action_about:
        intent = new Intent(this, AboutActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intent);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.handshake.notifications.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *//*from  w w  w  .ja v  a 2 s  .co m*/
private void sendNotification(final Bundle data, long userId, boolean isContact) {
    Intent intent;
    if (userId == 0) {
        intent = new Intent(this, MainActivity.class);
    } else if (isContact) {
        intent = new Intent(this, ContactUserProfileActivity.class);
    } else {
        intent = new Intent(this, GenericUserProfileActivity.class);
    }
    intent.putExtra("userId", userId);
    intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
            PendingIntent.FLAG_ONE_SHOT);

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle("Handshake")
            .setContentText(data.getString("message")).setAutoCancel(true).setSound(defaultSoundUri)
            .setContentIntent(pendingIntent);

    NotificationManager notificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
}

From source file:net.vivekiyer.GAL.CorporateAddressBook.java

@Override
protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction()))
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    super.onNewIntent(intent);
    setIntent(intent);//  w ww  . j  a v  a 2s. co  m
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        final String query = intent.getStringExtra(SearchManager.QUERY);
        performSearch(query);
    }
}

From source file:de.lespace.apprtc.ConnectChatActivity.java

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

    setContentView(R.layout.activity_connect);
    // Get setting keys.
    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
    sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
    missingPermissions = new ArrayList();

    for (String permission : MANDATORY_PERMISSIONS) {
        if (checkCallingOrSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
            missingPermissions.add(permission);
        }//w  w w .j av  a 2s . c o  m
    }
    requestPermission();

    //Bring Call2Front when
    bringToFrontBroadcastReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {

            Intent intentStart = new Intent(getApplicationContext(), ConnectChatActivity.class);
            // intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
            intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
            startActivity(intentStart);
            //  newFragment.show(transaction,"loading");

            //  showDialog();
        }
    };

    registerBringToFrontReceiver();

    if (checkPlayServices()) {
        // Start IntentService to register this application with GCM.
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);
    }

    ImageButton connectButton = (ImageButton) findViewById(R.id.connect_button);
    connectButton.setOnClickListener(connectListener);

    // If an implicit VIEW intent is launching the app, go directly to that URL.
    //final Intent intent = getIntent();
    Uri wsurl = Uri.parse(Configs.ROOM_URL);
    //intent.getData();
    Log.d(TAG, "connecting to:" + wsurl.toString());
    if (wsurl == null) {
        logAndToast(getString(R.string.missing_wsurl));
        Log.e(TAG, "Didn't get any URL in intent!");
        setResult(RESULT_CANCELED);
        finish();
        return;
    }

    if (from == null || from.length() == 0) {
        logAndToast(getString(R.string.missing_from));
        Log.e(TAG, "Incorrect from in intent!");
        setResult(RESULT_CANCELED);
        finish();
        return;
    }

    roomConnectionParameters = new AppRTCClient.RoomConnectionParameters(wsurl.toString(), from, false);

    Log.i(TAG, "creating appRtcClient with roomUri:" + wsurl.toString() + " from:" + from);
    // Create connection client and connection parameters.
    appRtcClient = new WebSocketRTCClient(this, new LooperExecutor());

    connectToWebsocket();
    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
}