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:edu.stanford.mobisocial.dungbeetle.feed.objects.AppReferenceObj.java

@Override
public void activate(Context context, SignedObj obj) {
    JSONObject content = obj.getJson();// ww w.  ja va 2 s . co m
    if (DBG)
        Log.d(TAG, "activating from appReferenceObj: " + content);

    if (!content.has(DbObject.CHILD_FEED_NAME)) {
        Log.wtf(TAG, "Bad app reference found.");
        Toast.makeText(context, "Could not launch application.", Toast.LENGTH_SHORT).show();
        return;
    }

    Log.w(TAG, "Using old-school app launch");
    SignedObj appContent = getAppStateForChildFeed(context, obj);
    if (appContent == null) {
        Intent launch = AppStateObj.getLaunchIntent(context, obj);
        if (!(context instanceof Activity)) {
            launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }

        context.startActivity(launch);
    } else {
        if (DBG)
            Log.d(TAG, "pulled app state " + appContent);
        try {
            appContent.getJson().put(PACKAGE_NAME, content.get(PACKAGE_NAME));
            appContent.getJson().put(OBJ_INTENT_ACTION, content.get(OBJ_INTENT_ACTION));
            appContent.getJson().put(DbObject.CHILD_FEED_NAME, content.get(DbObject.CHILD_FEED_NAME));
        } catch (JSONException e) {
        }
        //mAppStateObj.activate(context, appContent);
        Log.wtf(TAG, "dead code exception");
    }
}

From source file:app.androidhive.info.realm.GCM.GcmIntentService.java

private void sendNotification(String title, String msg, String link) {
    mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);

    /* Intent intent = new Intent(this, MainActivity.class);
     intent.putExtra("phone", link);/*from   w  ww .ja v a2s  .com*/
     PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);*/

    Phone = link;

    //   getData(link);

    Intent dialogIntent = new Intent(getBaseContext(), MainActivity.class);
    dialogIntent.putExtra("Phone", link);
    dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    getApplication().startActivity(dialogIntent);

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this)
            .setLargeIcon(BitmapFactory.decodeResource(getBaseContext().getResources(), R.mipmap.ic_launcher))
            .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(link).setAutoCancel(true)
            .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg);

    // Set the notification vibrate option
    if (preferences.getBoolean("notifications_new_message_vibrate", true)) {
        mBuilder.setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 });
    }
    // Set the notification ringtone
    if (preferences.getString("notifications_new_message_ringtone", null) != null) {
        mBuilder.setSound(Uri.parse(preferences.getString("notifications_new_message_ringtone", null)));
    } else {
        Uri alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        mBuilder.setSound(alarmSound);
    }

    // Show only if the notification are enabled
    if (preferences.getBoolean("notifications_new_message", true)) {
        //   mBuilder.setContentIntent(contentIntent);
        mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
    }

}

From source file:com.hybris.mobile.activity.BarCodeScannerActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        String contents = data.getStringExtra(SCAN_RESULT);
        String format = data.getStringExtra(SCAN_RESULT_FORMAT);

        Log.i(TAG, "Contents: " + contents);
        Log.i(TAG, "format: " + format);
        String isUseSpecificBaseUrl = Hybris
                .getSharedPreferenceString(InternalConstants.KEY_PREF_TOGGLE_SPECIFIC_BASE_URL);

        if (StringUtils.equals(isUseSpecificBaseUrl, String.valueOf(false))) {
            Log.i(TAG, "calling default handler for url: " + contents);
            // We run the task to check the format and data availability of the barcode scanned
            new CheckBarcodeFormatAndValueTask().execute(contents, format);
        } else {/* ww w  . jav  a  2 s  . c o  m*/
            //isScannerRunning = false;
            //            WebView myWebView = new WebView(this);
            //            myWebView = (WebView) findViewById(R.layout.app_web_view);
            Log.i(TAG, "calling webview activity with url: " + contents);
            //            myWebView.loadUrl(contents);
            //            WebSettings webSettings = myWebView.getSettings();
            //            webSettings.setJavaScriptEnabled(true);
            Intent localintent = new Intent(Hybris.getAppContext(), ScanCodeWebViewActivity.class);
            localintent.putExtra(Constants.DATA, contents);
            localintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            Log.i(TAG, "Sending intent to start webview for url");
            Hybris.getAppContext().startActivity(localintent);
        }
    } else if (resultCode == RESULT_CANCELED) {
        Message msg = new Message();
        msg.what = BarCodeScannerActivity.MSG_CANCEL_SCAN;
        mHandler.sendMessage(msg);
    }
}

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

protected void goListView(String mode) {
    if (mediaList.getMediaType() == MediaType.recordings
            && getAppSettings().getMediaSettings().getSortType() == SortType.byTitle)
        getAppSettings().clearCache(); // refresh since we're switching from flattened hierarchy

    if (getPath() == null || getPath().isEmpty()) {
        Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(MODE_SWITCH, mode);
        intent.putExtra(SEL_ITEM_INDEX, getSelItemIndex());
        startActivity(intent);/*from  ww w .j a va2 s .c o  m*/
    } else {
        Uri uri = new Uri.Builder().path(getPath()).build();
        Intent intent = new Intent(Intent.ACTION_VIEW, uri, getApplicationContext(), MediaListActivity.class);
        intent.putExtra(MODE_SWITCH, mode);
        intent.putExtra(SEL_ITEM_INDEX, getSelItemIndex());
        startActivity(intent);
    }
}

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

@Override
public void onBackPressed() {
    if (EpgActivity.class.getName().equals(backTo) || FireTvEpgActivity.class.getName().equals(backTo)) {
        Intent a = new Intent(Intent.ACTION_MAIN);
        a.addCategory(Intent.CATEGORY_HOME);
        a.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(a);// w  w  w.  j  a  va  2 s.c om
    } else if (modeSwitch) {
        modeSwitch = false;
        Intent intent = new Intent(this, MediaPagerActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
        finish();
    } else {
        super.onBackPressed();
    }
}

From source file:com.appteam.nimbus.activity.homeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    personalData = new PersonalData(this);
    if (personalData.getStatus() == false) {
        Intent i = new Intent(homeActivity.this, Login.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(i);/*w  w  w .j a  v  a2  s.  c  o  m*/
        finish();
    }

    setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    ImageView icon1 = (ImageView) findViewById(R.id.icon1);
    ImageView arrow1 = (ImageView) findViewById(R.id.arrow1);
    ImageView icon2 = (ImageView) findViewById(R.id.icon2);
    ImageView arrow2 = (ImageView) findViewById(R.id.arrow2);
    ImageView icon3 = (ImageView) findViewById(R.id.icon3);
    ImageView arrow3 = (ImageView) findViewById(R.id.arrow3);
    ImageView icon4 = (ImageView) findViewById(R.id.icon4);
    ImageView arrow4 = (ImageView) findViewById(R.id.arrow4);
    ImageView icon5 = (ImageView) findViewById(R.id.icon5);
    ImageView arrow5 = (ImageView) findViewById(R.id.arrow5);

    final int newColor = getResources().getColor(R.color.new_color);
    icon1.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow1.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon2.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow2.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon3.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow3.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon4.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow4.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    icon5.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);
    arrow5.setColorFilter(newColor, PorterDuff.Mode.SRC_ATOP);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    findViewById(R.id.department).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, DepartmentalTeam.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });

    findViewById(R.id.coreteam).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, CoreTeamActivity.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });

    findViewById(R.id.event).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, EventActivity.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });
    findViewById(R.id.welcome).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(homeActivity.this, AboutNimbusSplash.class);
            intent.putExtra(ABOUT_NIMBUS, "rule");
            startActivity(intent);
        }
    });
    findViewById(R.id.sponsors).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startActivity(new Intent(homeActivity.this, SponserActivity.class));
            overridePendingTransition(R.anim.open_next, R.anim.open_main);
        }
    });
}

From source file:fr.simon.marquis.preferencesmanager.ui.PreferencesActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        if (launchedFromShortcut) {
            Intent i = new Intent(this, AppListActivity.class);
            i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(i);//from  w w w .j  av  a2s.  co m
        }
        finish();
        return true;
    case R.id.action_fav:
        Utils.setFavorite(packageName, !Utils.isFavorite(packageName, this), this);
        invalidateOptionsMenu();
        break;
    case R.id.action_shortcut:
        createShortcut();
        Toast.makeText(this, R.string.toast_shortcut, Toast.LENGTH_SHORT).show();
        break;
    default:
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:de.grobox.blitzmail.SendActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // before doing anything show notification about sending process
    mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    mBuilder = new NotificationCompat.Builder(this);
    mBuilder.setContentTitle(getString(R.string.sending_mail)).setContentText(getString(R.string.please_wait))
            .setSmallIcon(R.drawable.notification_icon).setOngoing(true);
    // Sets an activity indicator for an operation of indeterminate length
    mBuilder.setProgress(0, 0, true);// w  ww .  j a  va 2  s . c om
    // Create Pending Intent
    notifyIntent = new Intent(this, NotificationHandlerActivity.class);
    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);
    mBuilder.setContentIntent(pendingIntent);
    // Issues the notification
    mNotifyManager.notify(0, mBuilder.build());

    Properties prefs;
    try {
        prefs = getPrefs();
    } catch (Exception e) {
        String msg = e.getMessage();

        Log.i("SendActivity", "ERROR: " + msg, e);

        if (e.getClass().getCanonicalName().equals("java.lang.RuntimeException") && e.getCause() != null
                && e.getCause().getClass().getCanonicalName().equals("javax.crypto.BadPaddingException")) {
            msg = getString(R.string.error_decrypt);
        }

        showError(msg);
        return;
    }

    // get and handle Intent
    Intent intent = getIntent();
    String action = intent.getAction();

    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    if (action.equals(Intent.ACTION_SEND)) {
        String text = intent.getStringExtra(Intent.EXTRA_TEXT);
        //String email   = intent.getStringExtra(Intent.EXTRA_EMAIL);
        String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
        String cc = intent.getStringExtra(Intent.EXTRA_CC);
        String bcc = intent.getStringExtra(Intent.EXTRA_BCC);

        // Check for empty content
        if (subject == null && text != null) {
            // cut all characters from subject after the 128th
            subject = text.substring(0, (text.length() < 128) ? text.length() : 128);
            // remove line breaks from subject
            subject = subject.replace("\n", " ").replace("\r", " ");
        } else if (subject != null && text == null) {
            text = subject;
        } else if (subject == null && text == null) {
            Log.e("Instant Mail", "Did not send mail, because subject and body empty.");
            showError(getString(R.string.error_no_body_no_subject));
            return;
        }

        // create JSON object with mail information
        mMail = new JSONObject();
        try {
            mMail.put("id", String.valueOf(new Date().getTime()));
            mMail.put("body", text);
            mMail.put("subject", subject);
            mMail.put("cc", cc);
            mMail.put("bcc", bcc);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        // remember mail for later
        MailStorage.saveMail(this, mMail);

        // pass mail on to notification dialog class
        notifyIntent.putExtra("mail", mMail.toString());

        // Start Mail Task
        AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail);
        mail.execute();
    } else if (action.equals("BlitzMailReSend")) {
        try {
            mMail = new JSONObject(intent.getStringExtra("mail"));
        } catch (JSONException e) {
            e.printStackTrace();
        }

        // pass mail on to notification dialog class
        notifyIntent.putExtra("mail", mMail.toString());

        // Start Mail Task
        AsyncMailTask mail = new AsyncMailTask(this, prefs, mMail);
        mail.execute();
    }
    finish();
}

From source file:com.mobage.android.shellappsdk.sample.GameWebView.java

private boolean handleExternalDomainUrl(String url) {
    Uri uri = Uri.parse(url);//from  w w  w .j  a  v  a 2s .  c  o  m
    String host = uri.getHost();
    if (mDomainWhiteList.containsHost(host)) {
        return false;
    }

    // No match - Sending Intent to External Browser
    if ("http".equalsIgnoreCase(uri.getScheme()) || "https".equalsIgnoreCase(uri.getScheme())) {
        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        if (getContext() instanceof Activity) {
            getContext().startActivity(intent);
        }
    }
    return true;
}

From source file:com.notifry.android.ChooseAccount.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Intent intent = new Intent(this, Notifry.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);//from w ww  .  j ava2s .c  o  m
        return true;
    case REFRESH_IDS:
        // Dispatch this to the updater service.
        Intent intentData = new Intent(getBaseContext(), UpdaterService.class);
        intentData.putExtra("type", "registration");
        intentData.putExtra("registration", C2DMessaging.getRegistrationId(this));
        startService(intentData);

        Toast.makeText(thisActivity, getString(R.string.background_refreshing), Toast.LENGTH_SHORT).show();
        return true;
    }

    return super.onOptionsItemSelected(item);
}