Example usage for android.content Intent addFlags

List of usage examples for android.content Intent addFlags

Introduction

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

Prototype

public @NonNull Intent addFlags(@Flags int flags) 

Source Link

Document

Add additional flags to the intent (or with existing flags value).

Usage

From source file:com.onebus.zxing.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        //Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }/* w  w  w  .  j  a v a  2 s. c o m*/
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();

        /***********************************************************************/
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//

        try {
            activity.handleDecode((Result) message.obj, barcode);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } //?        /***********************************************************************/
        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails, start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    case R.id.launch_product_query:
        Log.d(TAG, "Got product query message");
        String url = (String) message.obj;
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        activity.startActivity(intent);
        break;
    }
}

From source file:com.avanade.C2DMReceiver.java

@Override
public void onUnregistered(Context context) {
    Log.w("C2DMReceiver-onUnregistered", "got here!");
    //      String urlString = getResources().getString(
    //            R.string.WhatsNewAtDataServiceUnRegisterURL);
    String urlString = "https://mobileapi.whatsnewat.com/WNADataService.svc/UnRegisterAndroid?deviceID='"
            + LoginScreen.androidDevice_id + "'";
    HttpGet httpGet = new HttpGet(urlString);

    LoginScreen.httpFlag = 1;/*from   ww  w  .j a  va2  s  .  c  om*/
    HttpGetRequest token = new HttpGetRequest();
    httpGet.setHeader(Constants.emailId, LoginScreen.statEmailId);
    httpGet.setHeader(Constants.companyKey, LoginScreen.statCompKey);

    // obtain response XML from the server
    String xml = token.performGetRequest(httpGet);
    Intent dBUpdateIntent = new Intent(getBaseContext(), DatabaseUpdate.class);
    dBUpdateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    dBUpdateIntent.putExtra("unregister", true);
    getApplication().startActivity(dBUpdateIntent);
}

From source file:com.fangyuan.vpngate.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_refresh:
        refresh();/*from   w w  w . j a v  a 2  s.  c o m*/
        break;

    case R.id.menu_setting:
        Intent intent = new Intent(this, SettingsActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:co.uk.gauntface.cordova.plugin.gcmbrowserlaunch.PushNotificationReceiver.java

private void launchBrowserTask(Context context, String url, String packageName) {
    Log.v(C.TAG, "launchBrowserTask");
    Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    browserIntent.setPackage(packageName);
    browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    List<ResolveInfo> activitiesList = context.getPackageManager().queryIntentActivities(browserIntent, -1);
    if (activitiesList.size() > 0) {
        browserIntent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(browserIntent);
    } else {//from   w w  w.j  a va  2 s  . co  m
        Intent playStoreIntent = new Intent(Intent.ACTION_VIEW);
        playStoreIntent.setData(Uri.parse("market://details?id=" + packageName));
        playStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(playStoreIntent);
        /**Intent rawIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
        rawIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(rawIntent);**/
    }
}

From source file:jp.co.ipublishing.esnavi.helpers.android.AppActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final int id = item.getItemId();

    if (id == android.R.id.home) {
        final Intent intent = new Intent(this, MapActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
        startActivity(intent);/*from   w  ww  .j a v  a2  s  . co m*/
        return true;
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.avanade.C2DMReceiver.java

@Override
public void onRegistrered(Context context, String registrationId) {
    Log.w("C2DMReceiver-onRegistered", registrationId);

    String urlString = "https://mobileapi.whatsnewat.com/WNADataService.svc/RegisterAndroidDevice?deviceToken='"
            + registrationId + "'&deviceID='" + LoginScreen.androidDevice_id + "'";
    HttpGet httpGet = new HttpGet(urlString);

    // set header parameters with user-provided credentials

    LoginScreen.httpFlag = 1;/*  w  w  w  .  jav a  2  s .c o m*/
    HttpGetRequest token = new HttpGetRequest();
    httpGet.setHeader(Constants.emailId, LoginScreen.statEmailId);
    httpGet.setHeader(Constants.companyKey, LoginScreen.statCompKey);
    // obtain response XML from the server
    String xml = token.performGetRequest(httpGet);
    Intent dBUpdateIntent = new Intent(getBaseContext(), DatabaseUpdate.class);
    dBUpdateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    dBUpdateIntent.putExtra("DeviceId", registrationId);
    getApplication().startActivity(dBUpdateIntent);

    //      Intent dialogIntent = new Intent(getBaseContext(), NextPage.class);
    //      dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    //      getApplication().startActivity(dialogIntent);

}

From source file:com.oakesville.mythling.MediaListActivity.java

protected void handleEmptyMediaList() {
    // go to main
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);/*  w  ww .ja va2s.com*/
    finish();
}

From source file:com.oakesville.mythling.MediaListActivity.java

public void refresh() {
    super.refresh();
    getAppSettings().setLastLoad(0);//ww w. ja  v a2 s . c om
    Intent intent = new Intent(this, MainActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(intent);
    finish();
}

From source file:org.roman.findme.MyGcmListenerService.java

/**
 * Create and show a simple notification containing the received GCM message.
 *
 * @param message GCM message received./*from w ww . j av a2  s.c  o  m*/
 */
private void sendNotification(String message) {
    Intent intent = new Intent(this, MessageActivity.class);
    intent.putExtra("message", message);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    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("Message").setContentText(message)
            .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent);

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

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

    if (sharedPreferences.getBoolean("display_message", true)) {
        displayMessage(message);
    }
}

From source file:com.avanade.C2DMReceiver.java

@Override
protected void onMessage(Context context, Intent intent) {
    int flag = 0;
    Log.w("C2DMReceiver", intent.getStringExtra("Count"));
    String count = intent.getStringExtra("Count");
    ActivityManager activityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
    List<RunningAppProcessInfo> procInfos = activityManager.getRunningAppProcesses();
    for (int i = 0; i < procInfos.size(); i++) {
        if (procInfos.get(i).processName.equals("com.avanade")) {
            if (count.startsWith("com.avanade")) {
                count = getIntFromEndOfString(count);
                numberNoti = count;// w  w  w .j av  a 2s.  co  m
                flag = 1;
                break;
            }
        }
    }
    if (flag == 1) {
        Intent pushUpdateIntent = new Intent(getBaseContext(), PushUpdate.class);
        pushUpdateIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        //pushUpdateIntent.putExtra("unregister", true);
        getApplication().startActivity(pushUpdateIntent);
        flag = 0;
    } else {
        //         System.out.println(" the app is not runnning......do something");
        //Toast.makeText(getApplicationContext(), "Notification Received", Toast.LENGTH_SHORT).show();
    }
}