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.adarshahd.indianrailinfo.donate.TrainEnquiry.java

private void startDetailsActivity() {

    //For testing!!!
    /*File file = new File("/sdcard/train_details_trn_number.html");
    String result = "";/*from w  w  w .  j a  v  a2  s  .  c om*/
    try {
    FileInputStream stream = new FileInputStream(file);
    InputStreamReader readerStream = new InputStreamReader(stream);
    BufferedReader reader = new BufferedReader(readerStream);
    String str;
    while((str = reader.readLine()) != null) {
        result += str;
    }
    } catch (IOException e) {
    e.printStackTrace();
    }*/

    if (mPage.contains("unavailable")) {
        TextView tv = new TextView(mActivity);
        tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL));
        tv.setTextColor(Color.RED);
        tv.setTextSize(20);
        tv.setText(
                "Response from server: \n\n\"The requested service is currently unavailable. Please try again later\"");
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(tv);
        return;
    }
    if (mPage.contains("invalid")) {
        TextView tv = new TextView(mActivity);
        tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL));
        tv.setTextColor(Color.RED);
        tv.setTextSize(20);
        tv.setText("Invalid Station code! Please select the station code from drop down list.");
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(tv);
        return;
    }
    if (mPage.contains("No Matching Trains")) {
        TextView tv = new TextView(mActivity);
        tv.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL));
        tv.setTextColor(Color.RED);
        tv.setTextSize(20);
        tv.setText("No Matching train found! Please check the train number/name");
        mFrameLayout.removeAllViews();
        mFrameLayout.addView(tv);
        return;
    }

    //put the required intent data and start TrainEnquiryDetails activity.
    Intent intent = new Intent(this, TrainEnquiryDetails.class);
    intent.putExtra(TRAIN, mTrainNumber);
    intent.putExtra(SEARCH, searchUsingTrnNumber);
    intent.putExtra(PAGE, mPage);
    intent.putExtra(SRC, mACTFrom.getText().toString());
    intent.putExtra(DST, mACTTo.getText().toString());
    intent.putExtra(DAY_TRAVEL, mCal.get(Calendar.DAY_OF_MONTH));
    intent.putExtra(MONTH_TRAVEL, mCal.get(Calendar.MONTH));
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    //Try to parse the mTrainNumber;
    try {
        Integer.parseInt(mTrainNumber);
        isInteger = true;
    } catch (Exception e) {
        isInteger = false;
    }
    intent.putExtra(ISINT, isInteger);
    startActivity(intent);
}

From source file:com.eugene.fithealthmaingit.UI.SaveSearchAddItemActivityMain.java

private void saveMeal() {

    LogMeal logMeals = new LogMeal();
    logMeals.setMealId(food_id);//from  w  ww. j ava2s .  co  m
    logMeals.setMealChoice(mealType);
    logMeals.setMealName(mFoodName);
    if (llCalories.getVisibility() == View.VISIBLE)
        logMeals.setCalorieCount(Double.valueOf(mCalUpdate.getText().toString()));
    if (llFat.getVisibility() == View.VISIBLE)
        logMeals.setFatCount(Double.valueOf(mFattieUpdate.getText().toString()));
    if (llSat.getVisibility() == View.VISIBLE)
        logMeals.setSaturatedFat(Double.valueOf(mSaturatedFatUpdate.getText().toString()));
    if (llCholesterol.getVisibility() == View.VISIBLE)
        logMeals.setCholesterol(Double.valueOf(mCholesterolUpdate.getText().toString()));
    if (llSodium.getVisibility() == View.VISIBLE)
        logMeals.setSodium(Double.valueOf(mSodiumUpdate.getText().toString()));
    if (llCarbs.getVisibility() == View.VISIBLE)
        logMeals.setCarbCount(Double.valueOf(mCarbUpdate.getText().toString()));
    if (llFiber.getVisibility() == View.VISIBLE)
        logMeals.setFiber(Double.valueOf(mFiberUpdate.getText().toString()));
    if (llSugars.getVisibility() == View.VISIBLE)
        logMeals.setSugars(Double.valueOf(mSugarUpdate.getText().toString()));
    if (llProtein.getVisibility() == View.VISIBLE)
        logMeals.setProteinCount(Double.valueOf(mProUpdate.getText().toString()));
    if (llVitC.getVisibility() == View.VISIBLE)
        logMeals.setVitA(Double.valueOf(mVitAUpdate.getText().toString()));
    if (llVitC.getVisibility() == View.VISIBLE)
        logMeals.setVitC(Double.valueOf(mVitCUpdate.getText().toString()));
    if (llCalcium.getVisibility() == View.VISIBLE)
        logMeals.setCalcium(Double.valueOf(mCalciumUpdate.getText().toString()));
    if (llIron.getVisibility() == View.VISIBLE)
        logMeals.setIron(Double.valueOf(mIronUpdate.getText().toString()));

    if (favorite == true && !meal_favorite.equals("favorite")) {
        logMeals.setFavorite("favorite");
    } else {
        logMeals.setFavorite("not");
    }
    logMeals.setManualEntry("false");
    logMeals.setBrand(food_brand);
    logMeals.setServingSize(Double.valueOf(mServingg.getText().toString()));
    logMeals.setMealServing("Serving");
    logMeals.setDate(new Date());
    logMeals.setOrderFormat(OrderFormat.setMealFormat(mealType));
    logMeals.save();
    testing();
    Intent saveFinish = new Intent(this, MainActivity.class);
    saveFinish.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(saveFinish);
}

From source file:com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin.java

public void showAppSettings() {
    Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setData(Uri.parse("package:" + getContext().getPackageName()));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
    getContext().startActivity(intent);//from  w ww. j  av  a  2  s .  c om
}

From source file:in.neoandroid.neoupdate.neoUpdate.java

private void startUpdateApk(Uri installerUri) {
    MimeTypeMap myMime = MimeTypeMap.getSingleton();
    String mimeType = myMime.getMimeTypeFromExtension("apk");
    Intent intent = new Intent(Intent.ACTION_VIEW);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(installerUri, mimeType);//"application/vnd.android.package-archive");
    context.startActivity(intent);/*from w w w .j a  va  2s .c om*/
}

From source file:me.myatminsoe.myansms.Message.java

/**
 * Fetch MMS parts./*  w  w w .ja v a2 s  .  co m*/
 *
 * @param context {@link Context}
 */
private void fetchMmsParts(final Context context) {
    final ContentResolver cr = context.getContentResolver();
    Cursor cursor = cr.query(URI_PARTS, null, PROJECTION_PARTS[INDEX_MID] + " = ?",
            new String[] { String.valueOf(id) }, null);
    if (cursor == null || !cursor.moveToFirst()) {
        return;
    }
    final int iID = cursor.getColumnIndex(PROJECTION_PARTS[INDEX_ID]);
    final int iCT = cursor.getColumnIndex(PROJECTION_PARTS[INDEX_CT]);
    final int iText = cursor.getColumnIndex("text");
    do {
        final int pid = cursor.getInt(iID);
        final String ct = cursor.getString(iCT);

        // get part
        InputStream is = null;

        final Uri uri = ContentUris.withAppendedId(URI_PARTS, pid);
        if (uri == null) {

            continue;
        }
        try {
            is = cr.openInputStream(uri);
        } catch (IOException | NullPointerException e) {

        }
        if (is == null) {

            if (iText >= 0 && ct != null && ct.startsWith("text/")) {
                body = cursor.getString(iText);
            }
            continue;
        }
        if (ct == null) {
            continue;
        }
        if (ct.startsWith("image/")) {
            picture = BitmapFactory.decodeStream(is);
            final Intent i = new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(uri, ct);
            i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            contentIntent = i;
            continue; // skip the rest
        } else if (ct.startsWith("video/") || ct.startsWith("audio/")) {
            picture = BITMAP_PLAY;
            final Intent i = new Intent(Intent.ACTION_VIEW);
            i.setDataAndType(uri, ct);
            i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            contentIntent = i;
            continue; // skip the rest
        } else if (ct.startsWith("text/")) {
            body = fetchPart(is);
        }

        try {
            is.close();
        } catch (IOException e) {
        } // Ignore
    } while (cursor.moveToNext());
}

From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java

private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {

    if (barcode != null) {
        viewfinderView.drawResultBitmap(barcode);
    }/*from ww  w . j ava2s.  c  o  m*/

    long resultDurationMS;
    if (getIntent() == null) {
        resultDurationMS = DEFAULT_INTENT_RESULT_DURATION_MS;
    } else {
        resultDurationMS = getIntent().getLongExtra(Intents.Scan.RESULT_DISPLAY_DURATION_MS,
                DEFAULT_INTENT_RESULT_DURATION_MS);
    }

    if (resultDurationMS > 0) {
        String rawResultString = String.valueOf(rawResult);
        if (rawResultString.length() > 32) {
            rawResultString = rawResultString.substring(0, 32) + " ...";
        }
        statusView.setText(getString(resultHandler.getDisplayTitle()) + " : " + rawResultString);
    }

    //        if (copyToClipboard && !resultHandler.areContentsSecure()) {
    //            CharSequence text = resultHandler.getDisplayContents();
    //            ClipboardInterface.setText(text, this);
    //        }

    if (source == IntentSource.NATIVE_APP_INTENT) {

        // Hand back whatever action they requested - this can be changed to Intents.Scan.ACTION when
        // the deprecated intent is retired.
        Intent intent = new Intent(getIntent().getAction());
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
        intent.putExtra(Intents.Scan.RESULT, rawResult.toString());
        intent.putExtra(Intents.Scan.RESULT_FORMAT, rawResult.getBarcodeFormat().toString());
        byte[] rawBytes = rawResult.getRawBytes();
        if (rawBytes != null && rawBytes.length > 0) {
            intent.putExtra(Intents.Scan.RESULT_BYTES, rawBytes);
        }
        Map<ResultMetadataType, ?> metadata = rawResult.getResultMetadata();
        if (metadata != null) {
            if (metadata.containsKey(ResultMetadataType.UPC_EAN_EXTENSION)) {
                intent.putExtra(Intents.Scan.RESULT_UPC_EAN_EXTENSION,
                        metadata.get(ResultMetadataType.UPC_EAN_EXTENSION).toString());
            }
            Number orientation = (Number) metadata.get(ResultMetadataType.ORIENTATION);
            if (orientation != null) {
                intent.putExtra(Intents.Scan.RESULT_ORIENTATION, orientation.intValue());
            }
            String ecLevel = (String) metadata.get(ResultMetadataType.ERROR_CORRECTION_LEVEL);
            if (ecLevel != null) {
                intent.putExtra(Intents.Scan.RESULT_ERROR_CORRECTION_LEVEL, ecLevel);
            }
            @SuppressWarnings("unchecked")
            Iterable<byte[]> byteSegments = (Iterable<byte[]>) metadata.get(ResultMetadataType.BYTE_SEGMENTS);
            if (byteSegments != null) {
                int i = 0;
                for (byte[] byteSegment : byteSegments) {
                    intent.putExtra(Intents.Scan.RESULT_BYTE_SEGMENTS_PREFIX + i, byteSegment);
                    i++;
                }
            }
        }
        sendReplyMessage(R.id.return_scan_result, intent, resultDurationMS);

    } else if (source == IntentSource.PRODUCT_SEARCH_LINK) {

        // Reformulate the URL which triggered us into a query, so that the request goes to the same
        // TLD as the scan URL.
        int end = sourceUrl.lastIndexOf("/scan");
        String replyURL = sourceUrl.substring(0, end) + "?q=" + resultHandler.getDisplayContents()
                + "&source=zxing";
        sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);

    } else if (source == IntentSource.ZXING_LINK) {

        //            if (scanFromWebPageManager != null && scanFromWebPageManager.isScanFromWebPage()) {
        //                String replyURL = scanFromWebPageManager.buildReplyURL(rawResult, resultHandler);
        //                scanFromWebPageManager = null;
        //                sendReplyMessage(R.id.launch_product_query, replyURL, resultDurationMS);
        //            }

    }
}

From source file:com.towson.wavyleaf.Sighting.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        Intent mainIntent = new Intent(this, Main.class);
        mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(mainIntent);/*  w w w .ja v  a 2s .  c  o  m*/
        finish();
        return true;
    case R.id.menu_submit:
        //           Toast.makeText(getApplicationContext(), String.valueOf(currentEditableLocation.getTime()), Toast.LENGTH_SHORT).show();
        if (isAccurateLocation(currentEditableLocation)) {//if LocationListener is accurate
            // If all fields are filled out, minus Notes/Area infested
            if (verifyFields() == true) {
                Toast.makeText(getApplicationContext(), "Sighting recorded", Toast.LENGTH_SHORT).show();
                createJSONObject();
                finish();
            }
        } else if (requestUpdatesFromProvider() == null) // If no GPS
            Toast.makeText(getApplicationContext(), "Cannot submit without GPS signal", Toast.LENGTH_SHORT)
                    .show();
        else {
            // If all fields are filled out, minus Notes/Area infested
            if (verifyFields() == true) {
                Toast.makeText(getApplicationContext(), "Sighting recorded", Toast.LENGTH_SHORT).show();
                createJSONObject();
                // Restore preferences
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
                boolean tripEnabled = sp.getBoolean("TRIP_ENABLED", false);
                if (!tripEnabled) {
                    locationData.stop();
                }
                updateLocationTimer.cancel();
                finish();
            }
        }
        return true;
    case R.id.menu_refresh:
        mMap.clear();
        mapHasMarker = false;
        refresh();
        Toast.makeText(getApplicationContext(), "Location refreshed", Toast.LENGTH_SHORT).show();
        return true;
    case R.id.menu_legal:
        showDialog(LEGAL);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.evecom.android.web.Web0Activity.java

public Intent getFileIntent(File file) {
    // Uri uri = Uri.parse("http://m.ql18.com.cn/hpf10/1.pdf");
    Uri uri = Uri.fromFile(file);/*from w w w . j  a  va2  s .co  m*/
    String type = getMIMEType(file);
    Log.i("tag", "type=" + type);
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(uri, type);
    return intent;
}

From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java

@Override
public void onAsyncCompleteListener(PostResponse aMasterDataDtos, CallType type) {
    if (type == CallType.GET_STOP_CAR && aMasterDataDtos.getResponseCode() == 1) {
        Toast.makeText(GetAllVehicalDetails.this, "Car is deleted sucessfully", Toast.LENGTH_LONG).show();
        Intent intent = new Intent(this, UserDetail.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);//from   w  w w  .j  a  va  2  s .  c o  m
    } else {
        Toast.makeText(GetAllVehicalDetails.this, "Error in updation try again", Toast.LENGTH_LONG).show();
    }

}