Example usage for android.content Intent getExtras

List of usage examples for android.content Intent getExtras

Introduction

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

Prototype

public @Nullable Bundle getExtras() 

Source Link

Document

Retrieves a map of extended data from the intent.

Usage

From source file:com.github.ajasmin.telususageandroidwidget.ReportAccountErrorActivity.java

private void retriveAppWidgetId() {
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
    if (extras != null) {
        appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
    }/*from  w  w w. j  a  v a 2  s . c  o  m*/

    // Finish the activity if we don't receive an appWidgetId
    if (appWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID)
        finish();
}

From source file:com.example.office.ui.mail.MailItemFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mInflater = inflater;//from   w w w  .  j  a v a 2 s .c om
    View rootView = inflater.inflate(getFragmentLayoutId(), container, false);
    setHasOptionsMenu(true);

    try {
        Activity activity = getActivity();
        activity.getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);

        Intent intent = getActivity().getIntent();
        mail = (MailItem) intent.getExtras().get(getActivity().getString(R.string.intent_mail_key));
        displayMail(rootView);
        getActivity().setProgressBarIndeterminateVisibility(false);
    } catch (Exception e) {
        Logger.logApplicationException(e, getClass().getSimpleName() + ".onCreateView(): Error.");
    }

    return rootView;
}

From source file:cn.count.easydrive366.CarRegistrationActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == 0 && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        try {// ww w.ja  va  2s  .c o  m
            this.processMessage(1, new JSONObject(extras.getString("result")));
        } catch (JSONException e) {

            e.printStackTrace();
        }
    }
}

From source file:io.teak.sdk.GooglePlay.java

int getResponseCodeFromIntent(Intent i) {
    Object o = i.getExtras().get(RESPONSE_CODE);
    if (o == null) {
        Log.e(LOG_TAG, "Intent with no response code, assuming OK (known Google issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return (Integer) o;
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {//from  w ww .j a v a  2s .c  om
        Log.e(LOG_TAG, "Unexpected type for intent response code.");
        Log.e(LOG_TAG, o.getClass().getName());
        throw new RuntimeException("Unexpected type for intent response code: " + o.getClass().getName());
    }
}

From source file:com.example.wojtekswiderski.woahpaper.GcmIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Bundle extras = intent.getExtras();
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this);
    // The getMessageType() intent parameter must be the intent you received
    // in your BroadcastReceiver.
    String messageType = gcm.getMessageType(intent);

    word = extras.get("word").toString();
    sender = extras.get("sender").toString();

    if (!extras.isEmpty()) { // has effect of unparcelling Bundle
        /*//from w ww . j  ava  2 s  . c o m
         * Filter messages based on message type. Since it is likely that GCM will be
         * extended in the future with new message types, just ignore any message types you're
         * not interested in, or that you don't recognize.
         */
        if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
            sendNotification("Send error: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
            sendNotification("Deleted messages on server: " + extras.toString());
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {

            int results = numberResults();

            if (results > MAXRESULTS) {
                int start;
                int i = 0;
                do {
                    start = (int) (Math.random() * MAXRESULTS);
                    i++;
                } while (setWallPaper(start) && i <= 10);
            } else {
                int i = 0;
                do {
                    i++;
                } while (setWallPaper(i) && i <= 10);
            }

            sendNotification("Received " + word.substring(0, 1).toUpperCase() + word.substring(1) + " from "
                    + sender.substring(0, 1).toUpperCase() + sender.substring(1));
            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:no.uka.findmyapp.android.rest.client.RestIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.v(debug, "Inside onHandleIntent");
    Log.v(debug, "" + new Date() + ", In onHandleIntent for thread id = " + Thread.currentThread().getId());

    Bundle bundle = intent.getExtras();

    Log.v(debug, "onHandleIntent bundle recived");

    ServiceModel serviceModel = (ServiceModel) bundle.get(IntentMessages.SERVICE_MODEL_PACKAGE);

    Credentials credentials = (Credentials) bundle.get(IntentMessages.CREDENTIALS_PACKAGE);

    createRestProcessor(credentials);/* www.  java 2  s. co  m*/

    String userToken = "";
    if (bundle.containsKey(IntentMessages.USER_TOKEN_PACKAGE)) {
        userToken = (String) bundle.get(IntentMessages.USER_TOKEN_PACKAGE);
    }

    Log.v(debug, "onHandleIntent: Sending " + serviceModel + " to the rest processor");
    restProcessor.callRest(serviceModel, userToken);

    Log.v(debug, "" + new Date() + ", This thread is waked up.");
}

From source file:com.jaguarlandrover.auto.remote.vehicleentry.LockActivity.java

private void handleExtra(Intent intent) {
    Bundle extras = intent.getExtras();
    if (extras != null && extras.size() > 0) {
        for (String k : extras.keySet()) {
            Log.i(TAG, "k = " + k + " : " + extras.getString(k));
        }//from ww  w . j  av a 2  s  .  co m
    }
    if (extras != null && "dialog".equals(extras.get("_extra1"))) {
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
        alertDialogBuilder.setTitle("" + extras.get("_extra2"));
        alertDialogBuilder.setMessage("" + extras.get("_extra3")).setCancelable(false).setPositiveButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        alertDialogBuilder.create().show();
    }
}

From source file:com.example.michael.bumpy.EditDetailsActivity.java

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        Bitmap imageBitmap = (Bitmap) extras.get("data");
        imageButtonToUpdate.setImageBitmap(imageBitmap);
    }//from www  .  jav  a  2  s  . com
}

From source file:com.codebutler.farebot.activities.ReadingTagActivity.java

private void resolveIntent(Intent intent) {
    final TextView textView = (TextView) findViewById(R.id.textView);

    try {/*from  w ww  . j  a  v  a  2s .  com*/
        Bundle extras = intent.getExtras();

        final Tag tag = (Tag) extras.getParcelable("android.nfc.extra.TAG");
        ;
        final String[] techs = tag.getTechList();

        new AsyncTask<Void, String, MifareCard>() {
            Exception mException;

            @Override
            protected MifareCard doInBackground(Void... params) {
                try {
                    if (ArrayUtils.contains(techs, "android.nfc.tech.NfcB"))
                        return CEPASCard.dumpTag(tag.getId(), tag);
                    else if (ArrayUtils.contains(techs, "android.nfc.tech.IsoDep"))
                        return DesfireCard.dumpTag(tag.getId(), tag);
                    else
                        throw new UnsupportedTagException(techs, Utils.getHexString(tag.getId()));
                } catch (Exception ex) {
                    mException = ex;
                    return null;
                }
            }

            @Override
            protected void onPostExecute(MifareCard card) {
                if (mException != null) {
                    if (mException instanceof UnsupportedTagException) {
                        UnsupportedTagException ex = (UnsupportedTagException) mException;
                        new AlertDialog.Builder(ReadingTagActivity.this).setTitle("Unsupported Tag")
                                .setMessage(ex.getMessage()).setCancelable(false)
                                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface arg0, int arg1) {
                                        finish();
                                    }
                                }).show();
                    } else {
                        Utils.showErrorAndFinish(ReadingTagActivity.this, mException);
                    }
                    return;
                }

                try {
                    String cardXml = Utils.xmlNodeToString(card.toXML().getOwnerDocument());

                    ContentValues values = new ContentValues();
                    values.put(CardsTableColumns.TYPE, card.getCardType().toInteger());
                    values.put(CardsTableColumns.TAG_SERIAL, Utils.getHexString(card.getTagId()));
                    values.put(CardsTableColumns.DATA, cardXml);
                    values.put(CardsTableColumns.SCANNED_AT, card.getScannedAt().getTime());

                    Uri uri = getContentResolver().insert(CardProvider.CONTENT_URI_CARD, values);
                    startActivity(new Intent(Intent.ACTION_VIEW, uri));
                    finish();
                } catch (Exception ex) {
                    Utils.showErrorAndFinish(ReadingTagActivity.this, ex);
                }
            }

            @Override
            protected void onProgressUpdate(String... values) {
                textView.setText(values[0]);
            }

        }.execute();

    } catch (Exception ex) {
        Utils.showErrorAndFinish(this, ex);
    }
}

From source file:com.vendsy.bartsy.venue.GCMIntentService.java

@Override
protected void onMessage(Context context, Intent intent) {

    String message = (String) intent.getExtras().get(Utilities.EXTRA_MESSAGE);
    String count = (String) intent.getExtras().get("badgeCount");

    Log.i(TAG, "<=== pushNotification(" + message + ")");

    // Process the notification and if successful post a user-level notification
    if (message != null) {
        try {/*w w w  . j  a v  a 2  s.  c o  m*/
            JSONObject json = new JSONObject(message);
            String notifyMSG = processPushNotification(json);
            if (notifyMSG != null) {
                generateNotification(context, notifyMSG, count);
                Log.v(TAG, "<=== pushNotification result: " + notifyMSG);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}