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.dvn.vindecoder.ui.user.GetAllVehicalDetails.java

@Override
public void onBackPressed() {
    super.onBackPressed();
    if (CommonURL.USER_TYPE == 1) {
        Intent intent = new Intent(this, SellerDetail.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);/*from   w w w . ja  v a2  s .com*/
    } else {
        Intent intent = new Intent(this, UserDetail.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);
    }

}

From source file:com.moonpi.swiftnotes.MainActivity.java

@Override
public void onClick(View v) {
    // If new note button pressed, start edit note activity with new note request code
    if (v.getId() == R.id.newNote) {
        Intent intent = new Intent(this, EditActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

        intent.putExtra("requestCode", NEW_NOTE_REQUEST);

        startActivityForResult(intent, NEW_NOTE_REQUEST);
    }//from  w  w  w  .j ava 2s .co  m
}

From source file:org.linphone.LinphoneService.java

public void callState(final LinphoneCore lc, final LinphoneCall call, final State state, final String message) {
    Log.i(TAG, "new state [" + state + "]");
    if (state == LinphoneCall.State.IncomingReceived && !call.equals(mLinphoneCore.getCurrentCall())) {
        if (call.getReplacedCall() == null) {
            // no multicall support, just decline
            mLinphoneCore.terminateCall(call);
        } // otherwise it will be accepted automatically.

        return;//  w  w  w. j av  a 2 s.c  o m
    }
    if (state == LinphoneCall.State.IncomingReceived) {
        // wakeup linphone
        Intent lIntent = new Intent();
        lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        lIntent.putExtra("showAnswer", true);
        lIntent.putExtra("name", call.getRemoteAddress().getUserName());
        lIntent.setClass(this, CallingActivity.class);
        startActivity(lIntent);
        startRinging();
    }
    mHandler.post(new Runnable() {
        public void run() {
            if (CallingActivity.getDialer() != null)
                CallingActivity.getDialer().callState(lc, call, state, message);
        }
    });

    if (mCurrentCallState == LinphoneCall.State.IncomingReceived) {
        // previous state was ringing, so stop ringing
        stopRinging();
        // routeAudioToReceiver();
    }
    mCurrentCallState = state;
}

From source file:com.moonpi.swiftnotes.MainActivity.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Intent intent = new Intent(this, EditActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);

    try {//from   w  w  w. ja  v  a  2 s.c om
        // Package current note content and send to edit note activity
        intent.putExtra("title", notes.getJSONObject(position).getString("title"));
        intent.putExtra("body", notes.getJSONObject(position).getString("body"));
        intent.putExtra("colour", notes.getJSONObject(position).getString("colour"));
        intent.putExtra("fontSize", notes.getJSONObject(position).getInt("fontSize"));
        intent.putExtra("requestCode", position);

        startActivityForResult(intent, position);

    } catch (JSONException e) {
        e.printStackTrace();
    }
}

From source file:com.wojtechnology.sunami.TheBrain.java

private Notification.Builder getLollipopNotifBuilder(boolean isPlaying) {
    Intent notificationIntent = new Intent(this, MainActivity.class);
    notificationIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 1, notificationIntent, 0);

    Intent serviceLastIntent = new Intent(getApplicationContext(), TheBrain.class);
    serviceLastIntent.setAction(TheBrain.PLAY_LAST);
    serviceLastIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingLastIntent = PendingIntent.getService(mContext, 1, serviceLastIntent, 0);
    Intent servicePlayIntent = new Intent(getApplicationContext(), TheBrain.class);
    servicePlayIntent.setAction(TheBrain.TOGGLE_PLAY);
    servicePlayIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingPlayIntent = PendingIntent.getService(mContext, 1, servicePlayIntent, 0);
    Intent serviceNextIntent = new Intent(getApplicationContext(), TheBrain.class);
    serviceNextIntent.setAction(TheBrain.PLAY_NEXT);
    serviceNextIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingNextIntent = PendingIntent.getService(mContext, 1, serviceNextIntent, 0);
    Intent serviceStopIntent = new Intent(getApplicationContext(), TheBrain.class);
    serviceStopIntent.setAction(TheBrain.PLAY_STOP);
    serviceStopIntent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
    PendingIntent pendingStopIntent = PendingIntent.getService(mContext, 1, serviceStopIntent, 0);

    Notification.MediaStyle style = new Notification.MediaStyle();
    style.setShowActionsInCompactView(1, 2);
    Notification.Builder builder = new Notification.Builder(this).setSmallIcon(R.mipmap.sunaminotif)
            .setContentIntent(pendingIntent).setStyle(style);
    builder.addAction(R.drawable.ic_last_hint, "Last", pendingLastIntent);
    builder.addAction(isPlaying ? R.drawable.ic_pause_hint : R.drawable.ic_play_hint, "Play",
            pendingPlayIntent);/*from w ww  .ja  v a 2  s.  co m*/
    builder.addAction(R.drawable.ic_next_hint, "Next", pendingNextIntent);
    builder.addAction(R.drawable.ic_stop_notif, "Stop", pendingStopIntent);
    return builder;
}

From source file:com.almarsoft.GroundhogReader.MessageActivity.java

protected void attachClicked(final String attachcode) {

    HashMap<String, String> tmpattachPart = null;
    String tmpmd5 = null;/*from ww w. ja va 2 s  . c  o  m*/

    for (HashMap<String, String> part : mMimePartsVector) {
        tmpmd5 = part.get("md5");
        if (tmpmd5.equals(attachcode)) {
            tmpattachPart = part;
            break;
        }
    }

    final String md5 = tmpmd5;
    final HashMap<String, String> attachPart = tmpattachPart;

    if (attachPart != null && md5 != null) {

        new AlertDialog.Builder(this).setTitle(getString(R.string.attachment))
                .setMessage(getString(R.string.open_save_attach_question))
                .setPositiveButton(getString(R.string.open), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sumthin) {
                        Intent intent = new Intent();
                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        intent.setAction(android.content.Intent.ACTION_VIEW);
                        File attFile = new File(UsenetConstants.EXTERNALSTORAGE + "/" + UsenetConstants.APPNAME
                                + "/" + UsenetConstants.ATTACHMENTSDIR + "/" + mGroup, md5);
                        Uri attachUri = Uri.fromFile(attFile);
                        intent.setDataAndType(attachUri, attachPart.get("type"));
                        startActivity(intent);
                    }
                }).setNegativeButton(getString(R.string.save), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dlg, int sumthin) {
                        try {
                            String finalPath = FSUtils.saveAttachment(md5, mGroup, attachPart.get("name"));
                            Toast.makeText(MessageActivity.this, getString(R.string.saved_to) + finalPath,
                                    Toast.LENGTH_LONG).show();
                        } catch (IOException e) {
                            e.printStackTrace();
                            Toast.makeText(MessageActivity.this,
                                    getString(R.string.could_not_save_colon) + e.toString(), Toast.LENGTH_LONG)
                                    .show();
                        }
                    }
                }).show();
    }
}

From source file:hr.foicore.varazdinlandmarksdemo.POIMapActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int id = item.getItemId();
    if (id == R.id.action_view_as_grid) {
        Intent i = new Intent(POIMapActivity.this, POIGridActivity.class);

        i.putExtra("playOn", mActionPlay);

        i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        // finish();
        overridePendingTransition(0, 0);

        startActivityForResult(i, 1);/*w  w  w  .j av a  2s.  c om*/
        overridePendingTransition(0, 0);

    } else if (id == R.id.action_directions) {

        if (mActionDirections == 1) { // cancel directions action
            item.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        } else if (mActionDirections == 0) { // set directions action on

            item.setIcon(R.drawable.ic_action_directions_pressed);
            mActionDirections = 1;

            gmm.handleMapWarningMessages(POIMapActivity.this, tvMapMessage);
            if (gmm.myLocationEnabled && gmm.internetEnabled) {
                Toast.makeText(POIMapActivity.this,
                        POIMapActivity.this.getResources().getString(R.string.tap_route_destination),
                        Toast.LENGTH_SHORT).show();

            } else {
                tvMapMessage.setBackgroundColor(
                        POIMapActivity.this.getResources().getColor(R.color.red_transparent));

                item.setIcon(R.drawable.ic_action_directions);
                mActionDirections = 0;
                tvMapDirectionsInfo.setVisibility(View.INVISIBLE);

            }
        } else { // mActionDirections == 3
            item.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        }

    } else if (id == R.id.action_play) {

        if (mActionPlay) { // cancel play mode
            gmm.addAllMarkers(POIMapActivity.this);
            item.setIcon(R.drawable.ic_action_play);
            mActionPlay = false;

            miDirections.setIcon(R.drawable.ic_action_directions);
            mActionDirections = 0;
            tvMapDirectionsInfo.setVisibility(View.INVISIBLE);
            if (mRoute != null) {
                mRoute.remove();
            }
        } else {
            gmm.addPlayMarkers(POIMapActivity.this);
            item.setIcon(R.drawable.ic_action_pause_red);
            if (gmm.activePOIMarker != null) {
                drawUserDestRoute(gmm.activePOIMarker.getPosition());
            }
            mActionPlay = true;

        }

    } else if (id == R.id.action_google_map_type) {
        // get google map type names
        String[] googleMapTypeNames = getResources().getStringArray(R.array.google_map_type_names);

        // creating and Building the Dialog
        AlertDialog.Builder builderMapType = new AlertDialog.Builder(this);
        builderMapType.setTitle(getResources().getString(R.string.action_google_map_type));
        builderMapType.setSingleChoiceItems(googleMapTypeNames, selectedMapType,
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {

                        if (item != selectedMapType) {
                            switchGoogleMapType(item);
                            // save selected type in settings
                            SharedPreferences preferences = PreferenceManager
                                    .getDefaultSharedPreferences(POIMapActivity.this);
                            SharedPreferences.Editor editor = preferences.edit();
                            editor.putString("googleMapType", String.valueOf(item));
                            editor.commit();
                        }
                        mapTypeDialog.dismiss();
                    }
                });
        mapTypeDialog = builderMapType.create();
        mapTypeDialog.show();

    } else if (id == R.id.action_legal_notices) {

        String licenseInfo = GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
        AlertDialog.Builder licenseDialog = new AlertDialog.Builder(POIMapActivity.this);
        licenseDialog.setTitle(getString(R.string.action_legal_notices));
        licenseDialog.setMessage(licenseInfo);
        licenseDialog.show();

    } else if (id == R.id.action_scan_qr_code) {

        handleQRcodeScanRequest();

    } else if (id == R.id.action_about) {
        String about = getString(R.string.about_application);
        AlertDialog alertDialog;
        alertDialog = new AlertDialog.Builder(POIMapActivity.this).create();

        alertDialog.setTitle(getString(R.string.action_about));
        alertDialog.setMessage(Html.fromHtml(about));

        alertDialog.setButton(Dialog.BUTTON_NEGATIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
        alertDialog.show();
    }
    return super.onOptionsItemSelected(item);
}

From source file:net.mypapit.mobile.myrepeater.RepeaterListActivity.java

public void showAlertDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Manual Location");
    builder.setMessage(//from   ww  w.jav a2 s . c o  m
            "Note that this will not allow Repeater.MY to auto-detect location.\n\nDisable Location Service now?"); // Want
    // to
    // enable?

    // if yes - bring user to enable Location Service settings
    builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogInterface, int i) {

            Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            getApplicationContext().startActivity(intent);
        }
    });

    // if no - bring user to selecting Static Location Activity
    builder.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();

        }

    });
    builder.create().show();

}

From source file:net.oschina.app.v2.activity.zxing.CaptureActivity.java

private void handleDecodeExternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
    if (barcode != null) {
        viewfinderView.drawResultBitmap(barcode);
    }/*  w  w  w .  j av  a2s. 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);
        }
    }
}