Example usage for android.content Intent hasExtra

List of usage examples for android.content Intent hasExtra

Introduction

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

Prototype

public boolean hasExtra(String name) 

Source Link

Document

Returns true if an extra value is associated with the given name.

Usage

From source file:com.bellman.bible.android.view.activity.page.MainBibleActivity.java

/**
 * Called when the activity is first created.
 *//*from   ww w. j  ava  2 s  . c  o  m*/
@SuppressLint("MissingSuperCall")
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(TAG, "Creating MainBibleActivity");
    super.onCreate(savedInstanceState, true);
    Intent mIntent = getIntent();
    setContentView(R.layout.main_bible_view);

    ControlFactory.getInstance().provide(this);

    // create related objects
    BibleGestureListener gestureListener = new BibleGestureListener(MainBibleActivity.this);
    gestureDetector = new GestureDetectorCompat(this, gestureListener);

    windowControl = ControlFactory.getInstance().getWindowControl();

    documentViewManager = new DocumentViewManager(this);
    documentViewManager.buildView();

    bibleContentManager = new BibleContentManager(documentViewManager);

    mainMenuCommandHandler = new MenuCommandHandler(this);

    // register for passage change and appToBackground events
    EventBus.getDefault().register(this);
    // force the screen to be populated
    //th Passage Change Mediator class inits the whole bible layout
    PassageChangeMediator.getInstance().forcePageUpdate();
    if (mIntent.hasExtra(StartupActivity.EXTRA_BIBLE_URI)) {
        String uri = mIntent.getStringExtra(StartupActivity.EXTRA_BIBLE_URI).toString();
        BibleRef ref = getAllRefFromUri(uri);

        try {

            BibleBook book = BibleBook.values()[ref.getBook()];
            Versification v11n = ControlFactory.getInstance().getNavigationControl().getVersification();
            ControlFactory.getInstance().getCurrentPageControl().getCurrentBible()
                    .setKey(new Verse(v11n, book, ref.getChapter(), ref.getVerse()));
        } catch (Exception e) {

            Log.e(TAG, "error on select of bible book", e);
        }
    }

}

From source file:org.transdroid.core.gui.TorrentsActivity.java

@OnActivityResult(RESULT_DETAILS)
protected void onDetailsScreenResult(Intent result) {
    // If the details activity returns whether the torrent was removed or updated, update the torrents list as well
    // (the details fragment is the source, so no need to update that)
    if (result != null && result.hasExtra("affected_torrent")) {
        Torrent affected = result.getParcelableExtra("affected_torrent");
        fragmentTorrents.quickUpdateTorrent(affected, result.getBooleanExtra("torrent_removed", false));
    }//from  w  ww.  j a  v a 2  s  .  co  m
}

From source file:jp.mixi.android.sdk.MixiContainerImpl.java

private void callbackExecute(int resultCode, Intent data, CallbackListener listener) {
    if (resultCode == Activity.RESULT_OK) {
        listener.onComplete(data.getExtras());
        return;//from   w  w  w  .j av  a  2 s . c om
    } else {
        if (data != null && data.hasExtra(ERROR_STR)) {
            Log.d(TAG, data.getStringExtra(ERROR_STR));
            int code = data.getIntExtra(ERROR_CODE_STR, 0);
            if (code == ErrorInfo.SERVER_ERROR) {
                listener.onError(new ErrorInfo(data.getStringExtra(ERROR_MESSAGE_STR), code));
                return;
            } else if (code == ErrorInfo.OTHER_ERROR
                    && ACCOUNT_EXCEPTION.equals(data.getStringExtra(ERROR_STR))) {
                listener.onError(new ErrorInfo(data.getStringExtra(ERROR_MESSAGE_STR),
                        ErrorInfo.OFFICIAL_APP_ACCOUNT_ERROR));
                return;
            }
            listener.onFatal(new ErrorInfo(data.getStringExtra(ERROR_MESSAGE_STR), code));
            return;
        }
        Log.d(TAG, "Login canceled by user.");
        listener.onCancel();
        return;
    }
}

From source file:com.yeldi.yeldibazaar.AppDetails.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("lightTheme", false))
        setTheme(R.style.AppThemeLight);

    super.onCreate(savedInstanceState);
    ActionBarCompat abCompat = ActionBarCompat.create(this);
    abCompat.setDisplayHomeAsUpEnabled(true);

    setContentView(R.layout.appdetails);

    Intent i = getIntent();
    appid = "";//from  w  w  w  . j  av a2  s .c  om
    Uri data = getIntent().getData();
    if (data != null) {
        if (data.isHierarchical()) {
            if (data.getHost().equals("details")) {
                // market://details?id=app.id
                appid = data.getQueryParameter("id");
            } else {
                // https://f-droid.org/app/app.id
                appid = data.getLastPathSegment();
            }
        } else {
            // fdroid.app:app.id (old scheme)
            appid = data.getEncodedSchemeSpecificPart();
        }
        Log.d("FDroid", "AppDetails launched from link, for '" + appid + "'");
    } else if (!i.hasExtra("appid")) {
        Log.d("FDroid", "No application ID in AppDetails!?");
    } else {
        appid = i.getStringExtra("appid");
    }

    // Set up the list...
    headerView = new LinearLayout(this);
    ListView lv = (ListView) findViewById(android.R.id.list);
    lv.addHeaderView(headerView);
    ApkListAdapter la = new ApkListAdapter(this, null);
    setListAdapter(la);

    mPm = getPackageManager();
    // Get the preferences we're going to use in this Activity...
    AppDetails old = (AppDetails) getLastNonConfigurationInstance();
    if (old != null) {
        copyState(old);
    } else {
        if (!reset()) {
            finish();
            return;
        }
        resetRequired = false;
    }
    startViews();

}

From source file:com.stfalcon.contentmanager.ContentManager.java

private void handleFileContent(final Intent intent) {
    List<String> uris = new ArrayList<>();
    if (intent.getDataString() != null) {
        String uri = intent.getDataString();
        uris.add(uri);/*  w w  w  . j a v  a  2  s  .  c om*/
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        if (intent.getClipData() != null) {
            ClipData clipData = intent.getClipData();
            for (int i = 0; i < clipData.getItemCount(); i++) {
                ClipData.Item item = clipData.getItemAt(i);
                Log.d("TAG", "Item [" + i + "]: " + item.getUri().toString());
                uris.add(item.getUri().toString());
            }
        }
    }
    if (intent.hasExtra("uris")) {
        ArrayList<Uri> paths = intent.getParcelableArrayListExtra("uris");
        for (int i = 0; i < paths.size(); i++) {
            uris.add(paths.get(i).toString());
        }
    }

    //TODO Handle multiple file choose
    processFile(uris.get(0));
}

From source file:com.todotxt.todotxttouch.TodoTxtTouch.java

@Override
protected void onResume() {
    super.onResume();
    m_app.getStoredSort();/*from   ww  w.  j a  v  a  2  s.com*/
    m_app.getStoredFilters();
    setFilteredTasks(true);

    // Select the specified item if one was passed in to this activity
    // e.g. from the widget
    Intent intent = this.getIntent();

    if (intent.hasExtra(Constants.EXTRA_TASK)) {
        int position = getPositionFromId(intent.getLongExtra(Constants.EXTRA_TASK, 0));
        intent.removeExtra(Constants.EXTRA_TASK);
        getListView().setItemChecked(position, true);
    }

    // Show contextactionbar if there is a selection
    showContextActionBarIfNeeded();
}

From source file:com.mobicage.rogerthat.plugins.messaging.ServiceMessageDetailActivity.java

@Override
protected void onServiceBound() {
    T.UI();// w  ww .  j  ava2  s  .com
    mFriendsPlugin = mService.getPlugin(FriendsPlugin.class);
    mMessagingPlugin = mService.getPlugin(MessagingPlugin.class);
    mStore = mMessagingPlugin.getStore();
    mDisplayWidth = UIUtils.getDisplayWidth(this);

    final View activityView = LayoutInflater.from(this).inflate(R.layout.message_detail, null);

    ((ImageButton) activityView.findViewById(R.id.expand)).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            expandDetails();
        }
    });

    mStatusImage = (ImageView) activityView.findViewById(R.id.status_image);

    setContentView(activityView);
    activity = (RelativeLayout) activityView;

    final Intent intent = getIntent();
    String messageKey = intent.getStringExtra("message");
    mCurrentMessage = mStore.getFullMessageByKey(messageKey);

    if (intent.hasExtra("submitToJSMFR")) {
        messageSubmitToJsMfr(intent, intent.getAction());
    }

    updateView(false);

    if (MainActivity.ACTION_NOTIFICATION_PHOTO_UPLOAD_DONE.equals(intent.getAction()))
        animateAfterAck(2);
    mBroadcastReceiver = getBroadcastReceiver();
    final IntentFilter filter = getIntentFilter();
    registerReceiver(mBroadcastReceiver, filter);

    ((TextView) findViewById(R.id.show_magic_message_header))
            .setText(getString(R.string.show_message_header, getString(R.string.app_name)));
}

From source file:reportsas.com.formulapp.Formulario.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == 1) {
        if (data != null) {
            if (data.hasExtra("data")) {

                Bitmap photobmp = (Bitmap) data.getParcelableExtra("data");

                // iv.setImageBitmap(photobmp);
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                photobmp.compress(Bitmap.CompressFormat.JPEG, 100, baos);
                byte[] imageBytes = baos.toByteArray();
                String encodedImage = Base64.encodeToString(imageBytes, Base64.DEFAULT);

                if (parametroCam == null) {
                    parametroCam = new ParametrosRespuesta(2);
                }//from   w ww  . j  a va  2  s. c o  m

                parametroCam.setValor(encodedImage);

                // prueba.setText(encodedImage);
                //    new MyAsyncTask(Formulario.this)
                //          .execute("POST",encodedImage, HTTP_EVENT);
            }

        }
    }

    if (requestCode == MY_REQUEST_CODE && resultCode == Pdf417ScanActivity.RESULT_OK) {
        // First, obtain scan results array. If scan was successful, array will contain at least one element.
        // Multiple element may be in array if multiple scan results from single image were allowed in settings.

        Parcelable[] resultArray = data
                .getParcelableArrayExtra(Pdf417ScanActivity.EXTRAS_RECOGNITION_RESULT_LIST);

        StringBuilder sb = new StringBuilder();

        for (Parcelable p : resultArray) {
            if (p instanceof Pdf417ScanResult) { // check if scan result is result of Pdf417 recognizer
                Pdf417ScanResult result = (Pdf417ScanResult) p;
                // getStringData getter will return the string version of barcode contents
                String barcodeData = result.getStringData();

                // isUncertain getter will tell you if scanned barcode contains some uncertainties
                boolean uncertainData = result.isUncertain();
                // getRawData getter will return the raw data information object of barcode contents
                BarcodeDetailedData rawData = result.getRawData();
                // BarcodeDetailedData contains information about barcode's binary layout, if you
                // are only interested in raw bytes, you can obtain them with getAllData getter
                byte[] rawDataBuffer = rawData.getAllData();
                DataR = rawData.toString();

                String[] arrayElements = DataR.split("Element #");
                String Nombre = "", Apellido = "", cedula = "", fecha = "", dia, mes, ano;
                if (arrayElements.length >= 7) {
                    String[] auxliarArray = arrayElements[7].split("decoded\\):");

                    String strDatos = auxliarArray[1];
                    char[] ca = strDatos.toCharArray();
                    for (int i = 0; i < strDatos.length(); i++) {
                        if (Character.isLetter(ca[i])) //Si es letra
                            Apellido += ca[i]; //Salto de lnea e imprimimos el carcter
                        else //Si no es letra
                            cedula += ca[i]; //Imprimimos el carcter
                    }
                    Apellido = Apellido.trim();
                    cedula = (cedula.replaceAll("\n", "")).trim();
                    if (cedula.length() == 0) {
                        auxliarArray = arrayElements[5].split("decoded\\):");
                        strDatos = auxliarArray[1];
                        ca = strDatos.toCharArray();
                        Apellido = "";
                        for (int i = 0; i < strDatos.length(); i++) {
                            if (Character.isLetter(ca[i])) //Si es letra
                                Apellido += ca[i]; //Salto de lnea e imprimimos el carcter
                            else //Si no es letra
                                cedula += ca[i]; //Imprimimos el carcter
                        }
                        Apellido = Apellido.trim();
                        cedula = (cedula.replaceAll("\n", "")).trim();
                        cedula = cedula.substring(cedula.length() - 10, cedula.length());
                        cedula = eliminarceros(cedula);
                        auxliarArray = arrayElements[9].split("decoded\\):");
                        Nombre = (auxliarArray[1].replaceAll("\n", "")).trim();

                    } else {

                        cedula = eliminarceros(cedula);
                        auxliarArray = arrayElements[11].split("decoded\\):");
                        Nombre = (auxliarArray[1].replaceAll("\n", "")).trim();
                    }

                    auxliarArray = result.getStringData().toString().split(Nombre);
                    strDatos = auxliarArray[1];
                    ca = strDatos.toCharArray();
                    Boolean result_ciclo = true;
                    int i = 0;
                    while (result_ciclo) {
                        if (Character.isDigit(ca[i])) {
                            fecha += ca[i];
                        }
                        if (fecha.length() >= 9) {
                            result_ciclo = false;
                        }
                        i++;
                    }
                    fecha = fecha.substring(1, fecha.length());
                } else {
                    int puntoI = 0;
                    if (barcodeData.indexOf("1F") > 0) {
                        puntoI = barcodeData.indexOf("1F");
                    } else if (barcodeData.indexOf("0M") > 0) {
                        puntoI = barcodeData.indexOf("0M");
                    } else if (barcodeData.indexOf("0F") > 0) {
                        puntoI = barcodeData.indexOf("0F");
                    } else if (barcodeData.indexOf("1M") > 0) {
                        puntoI = barcodeData.indexOf("1M");
                    } else {

                    }
                    if (puntoI > 0) {
                        String seb = barcodeData.substring(1, puntoI);
                        fecha = barcodeData.substring(puntoI + 2, puntoI + 10);

                        int posL = 0, posE;
                        char[] ca = seb.toCharArray();
                        for (int w = seb.length() - 1; w > 0; w--) {
                            if (Character.isLetter(ca[w])) {
                                posL = w;
                                break;
                            }
                        }
                        seb = seb.substring(1, posL + 1);
                        ca = seb.toCharArray();
                        for (int w = seb.length() - 1; w > 0; w--) {
                            if (Character.isLetter(ca[w])) {
                                Nombre = ca[w] + Nombre;
                                posL = w;
                            } else {
                                break;
                            }
                        }
                        seb = seb.substring(1, posL);
                        ca = seb.toCharArray();
                        for (int w = seb.length() - 1; w > 0; w--) {
                            if (Character.isDigit(ca[w])) {
                                posL = w;
                                break;
                            }
                        }

                        for (int w = posL + 1; w <= seb.length(); w++) {
                            if (Character.isLetter(ca[w])) {
                                Apellido += ca[w];
                            } else {
                                break;
                            }
                        }

                        cedula = seb.substring(posL - 9, posL + 1);
                        cedula = eliminarceros(cedula);
                    } else {
                        fecha = "";
                    }
                }
                if (fecha.length() == 0) {
                    parametroScan = null;

                    Toast toast1 = Toast.makeText(this, "Los datos de codigo no pudieron ser interpretados!",
                            Toast.LENGTH_SHORT);

                    toast1.show();

                } else {
                    dia = fecha.substring(6, 8);
                    mes = fecha.substring(4, 6);
                    ano = fecha.substring(0, 4);
                    fecha = dia + "/" + mes + "/" + ano;

                    Infocadena = "Nombre: \n" + Nombre + ".\nApellido: \n" + Apellido + ". \nCedula: \n"
                            + cedula + ". \nFecha de Nacimiento: \n" + fecha + ".";
                    if (parametroScan == null) {
                        parametroScan = new ParametrosRespuesta(3);

                    }
                    parametroScan.setValor(Infocadena);

                }

                //  new MyAsyncTask(Formulario.this)
                //        .execute("POST",Infocadena, HTTP_EVENT);

            } else if (p instanceof BarDecoderScanResult) { // check if scan result is result of BarDecoder recognizer
                /* BarDecoderScanResult result = (BarDecoderScanResult) p;
                 // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode
                 BarcodeType type = result.getBarcodeType();
                 // as with PDF417, getStringData will return the string contents of barcode
                 String barcodeData = result.getStringData();
                 if(checkIfDataIsUrlAndCreateIntent(barcodeData)) {
                return;
                 } else {
                sb.append(type.name());
                sb.append(" string data:\n");
                sb.append(barcodeData);
                sb.append("\n\n\n");=
                 }*/
            } else if (p instanceof ZXingScanResult) { // check if scan result is result of ZXing recognizer
                /* ZXingScanResult result= (ZXingScanResult) p;
                 // with getBarcodeType you can obtain barcode type enum that tells you the type of decoded barcode
                 BarcodeType type = result.getBarcodeType();
                 // as with PDF417, getStringData will return the string contents of barcode
                 String barcodeData = result.getStringData();
                 if(checkIfDataIsUrlAndCreateIntent(barcodeData)) {
                return;
                 } else {
                sb.append(type.name());
                sb.append(" string data:\n");
                sb.append(barcodeData);
                sb.append("\n\n\n");
                 }*/
            } else if (p instanceof USDLScanResult) { // check if scan result is result of US Driver's Licence recognizer
                USDLScanResult result = (USDLScanResult) p;

                // USDLScanResult can contain lots of information extracted from driver's licence
                // you can obtain information using the getField method with keys defined in
                // USDLScanResult class

                String name = result.getField(USDLScanResult.kCustomerFullName);

                sb.append(result.getTitle());
                sb.append("\n\n");
                sb.append(result.toString());
            }
        }

    }
}

From source file:com.songcode.materialnotes.ui.NoteEditActivity.java

private boolean initActivityState(Intent intent) {
    /**//from  ww  w  .  ja v  a  2 s.com
     * If the user specified the {@link Intent#ACTION_VIEW} but not provided with id,
     * then jump to the NotesListActivity
     */
    mWorkingNote = null;
    if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {
        long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);
        mUserQuery = "";

        /**
         * Starting from the searched result
         */
        if (intent.hasExtra(SearchManager.EXTRA_DATA_KEY)) {
            noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
            mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY);
        }

        if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) {
            Intent jump = new Intent(this, NotesListActivity.class);
            startActivity(jump);
            showToast(R.string.error_note_not_exist);
            finish();
            return false;
        } else {
            mWorkingNote = WorkingNote.load(this, noteId);
            if (mWorkingNote == null) {
                Log.e(TAG, "load note failed with note id" + noteId);
                finish();
                return false;
            }
        }
    } else if (TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
        // New note
        long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0);
        int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        int widgetType = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_TYPE, Notes.TYPE_WIDGET_INVALIDE);
        int bgResId = intent.getIntExtra(Notes.INTENT_EXTRA_BACKGROUND_ID, ResourceParser.getDefaultBgId(this));

        // Parse call-record note
        String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        long callDate = intent.getLongExtra(Notes.INTENT_EXTRA_CALL_DATE, 0);
        if (callDate != 0 && phoneNumber != null) {
            if (TextUtils.isEmpty(phoneNumber)) {
                Log.w(TAG, "The call record number is null");
            }
            long noteId = 0;
            if ((noteId = DataUtils.getNoteIdByPhoneNumberAndCallDate(getContentResolver(), phoneNumber,
                    callDate)) > 0) {
                mWorkingNote = WorkingNote.load(this, noteId);
                if (mWorkingNote == null) {
                    Log.e(TAG, "load call note failed with note id" + noteId);
                    finish();
                    return false;
                }
            } else {
                mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId);
                mWorkingNote.convertToCallNote(phoneNumber, callDate);
            }
        } else {
            mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType, bgResId);
        }
    } else {
        Log.e(TAG, "Intent not specified action, should not support");
        finish();
        return false;
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
            | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    mWorkingNote.setOnSettingStatusChangedListener(this);
    return true;
}

From source file:com.hughes.android.dictionary.DictionaryActivity.java

@Override
/**//  w  w  w.j ava2 s  .c  o m
 * Invoked when MyWebView returns, since the user might have clicked some
 * hypertext in the MyWebView.
 */
protected void onActivityResult(int requestCode, int resultCode, Intent result) {
    super.onActivityResult(requestCode, resultCode, result);
    if (result != null && result.hasExtra(C.SEARCH_TOKEN)) {
        Log.d(LOG, "onActivityResult: " + result.getStringExtra(C.SEARCH_TOKEN));
        jumpToTextFromHyperLink(result.getStringExtra(C.SEARCH_TOKEN), indexIndex);
    }
}