Example usage for android.content Intent getStringExtra

List of usage examples for android.content Intent getStringExtra

Introduction

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

Prototype

public String getStringExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

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

public void checkActivityResultForPurchase(int resultCode, Intent data) {
    String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA);
    String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE);

    Log.d(LOG_TAG, "Checking activity result for purchase.");

    // Check for purchase activity result
    if (purchaseData != null && dataSignature != null) {
        int responseCode = getResponseCodeFromIntent(data);

        if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) {
            try {
                JSONObject json = new JSONObject(purchaseData);
                Teak.purchaseSucceeded(json);
            } catch (Exception e) {
                Log.e(LOG_TAG, "Failed to convert purchase data to JSON.");
                Teak.sdkRaven.reportException(e);
            }/*from  ww  w. j  a va 2 s  .  co m*/
        } else {
            Teak.purchaseFailed(responseCode);
        }
    } else {
        Log.d(LOG_TAG, "No purchase found in activity result.");
    }
}

From source file:org.klnusbaum.udj.network.EventCommService.java

private void setEventData(Intent intent, AccountManager am, Account account) {
    am.setUserData(account, Constants.EVENT_NAME_DATA, intent.getStringExtra(Constants.EVENT_NAME_EXTRA));
    am.setUserData(account, Constants.EVENT_HOSTNAME_DATA,
            intent.getStringExtra(Constants.EVENT_HOSTNAME_EXTRA));
    am.setUserData(account, Constants.EVENT_HOST_ID_DATA,
            String.valueOf(intent.getLongExtra(Constants.EVENT_HOST_ID_EXTRA, -1)));
    am.setUserData(account, Constants.EVENT_LAT_DATA,
            String.valueOf(intent.getDoubleExtra(Constants.EVENT_LAT_EXTRA, -100.0)));
    am.setUserData(account, Constants.EVENT_LONG_DATA,
            String.valueOf(intent.getDoubleExtra(Constants.EVENT_LONG_EXTRA, -100.0)));
}

From source file:org.mrquiz.android.tinyurl.SendTinyUrlActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    mUrl = intent.getStringExtra(Intent.EXTRA_TEXT);
    if (mUrl == null) {
        // Use a default URL if the activity is launched directly.
        mUrl = "http://www.google.com/";
    }//from   ww w.j  a  v  a2  s  .c o m

    //moveTaskToBack(true);

    // Request a TinyShare on a background thread.
    // This request is fast, so don't worry about the activity being
    // re-created if the keyboard is opened.
    new Thread(this).start();
}

From source file:com.example.ronald.tracle.RegistrationIntentService.java

@Override
protected void onHandleIntent(Intent intent) {
    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    String username = intent.getStringExtra("name");
    String password = intent.getStringExtra("password");

    try {/*from ww  w . ja  v a2  s  . c  o  m*/
        // [START register_for_gcm]
        // Initially this call goes out to the network to retrieve the token, subsequent calls
        // are local.
        // [START get_token]
        InstanceID instanceID = InstanceID.getInstance(this);
        String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId),
                GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
        // [END get_token]
        Log.i(TAG, "GCM Registration Token: " + token);

        // TODO: Implement this method to send any registration to your app's servers.
        sendRegistrationToServer(token, username, password);

        // Subscribe to topic channels
        subscribeTopics(token);

        // You should store a boolean that indicates whether the generated token has been
        // sent to your server. If the boolean is false, send the token to your server,
        // otherwise your server should have already received the token.
        sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, true).apply();
        // [END register_for_gcm]
    } catch (Exception e) {
        Log.d(TAG, "Failed to complete token refresh", e);
        // If an exception happens while fetching the new token or updating our registration data
        // on a third-party server, this ensures that we'll attempt the update at a later time.
        sharedPreferences.edit().putBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false).apply();
    }
    // Notify UI that registration has completed, so the progress indicator can be hidden.
    Intent registrationComplete = new Intent(QuickstartPreferences.REGISTRATION_COMPLETE);
    LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete);
}

From source file:com.plugin.gallery.ForegroundGalleryLauncher.java

/**
 * Called when the camera view exits./*from w  w  w .j a v  a2  s.c  o m*/
 * 
 * @param requestCode
 *            The request code originally supplied to
 *            startActivityForResult(), allowing you to identify who this
 *            result came from.
 * @param resultCode
 *            The integer result code returned by the child activity through
 *            its setResult().
 * @param intent
 *            An Intent, which can return result data to the caller (various
 *            data can be attached to Intent "extras").
 */
@Override
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    if (resultCode == Activity.RESULT_OK) {

        Uri uri = intent.getData();
        String fileURL = intent.getStringExtra("fileURL");
        System.out.println("fileURL = " + fileURL);
        ContentResolver resolver = this.cordova.getActivity().getContentResolver();

        try {
            Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
            bitmap = scaleBitmap(bitmap);
            this.processPicture(bitmap);
            bitmap.recycle();
            bitmap = null;
            this.callbackContext.success("" + fileURL);
            System.gc();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            this.failPicture("Error retrieving image.");
        }
    } else if (resultCode == Activity.RESULT_CANCELED) {
        this.failPicture("Selection cancelled.");
    } else {
        this.failPicture("Selection did not complete!");
    }
}

From source file:org.peterbaldwin.client.android.tinyurl.SendTinyUrlActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.title_creating);//www .java  2 s  .  co m
    setContentView(R.layout.send);
    mTextOriginalUrl = (TextView) findViewById(R.id.text_original_url);
    mProgressUrl = (ProgressBar) findViewById(R.id.progress_url);
    mTextUrl = (TextView) findViewById(R.id.text_url);
    mButtonSend = (Button) findViewById(R.id.button_send);
    mButtonCopy = (Button) findViewById(R.id.button_copy);
    mButtonCancel = (Button) findViewById(R.id.button_cancel);

    mButtonSend.setOnClickListener(this);
    mButtonCopy.setOnClickListener(this);
    mButtonCancel.setOnClickListener(this);

    // Disable these buttons until the TinyURL has been created.
    mButtonSend.setEnabled(false);
    mButtonCopy.setEnabled(false);

    Intent intent = getIntent();
    mUrl = intent.getStringExtra(Intent.EXTRA_TEXT);
    if (mUrl == null) {
        // Use a default URL if the activity is launched directly.
        mUrl = "http://www.google.com/";
    }

    mTextOriginalUrl.setText(mUrl);

    // Request a TinyURL on a background thread.
    // This request is fast, so don't worry about the activity being
    // re-created if the keyboard is opened.
    new Thread(this).start();
}

From source file:edu.mit.media.realityanalysis.fieldtest.MainPipeline.java

@Override
protected void onHandleIntent(Intent intent) {
    if (ACTION_RUN_ONCE.equals(intent.getAction())) {
        String probeName = intent.getStringExtra(RUN_ONCE_PROBE_NAME);
        runProbeOnceNow(probeName);/*from   w w  w  .j a  v  a 2 s. c o m*/
    } else if (ACTION_UPLOAD_DATA.equals(intent.getAction())) {
        uploadData();
    } else {
        super.onHandleIntent(intent);
    }
}

From source file:com.ateam.alleneatonautorentals.SalesViewReservations.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.view_reservations);

    Intent getIntent = getIntent();
    userEmail = getIntent.getStringExtra("email");
    key = getIntent.getStringExtra("key");
    name = getIntent.getStringExtra("name");

    resList = new ArrayList<HashMap<String, String>>();

    new LoadAllUserRes().execute();

    ListView lv = getListView();//  w w w .ja  va  2s . c om

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String gps = ((TextView) view.findViewById(R.id.carres_GPS_list)).getText().toString();
            String child_seat = ((TextView) view.findViewById(R.id.carres_child_seat_list)).getText()
                    .toString();
            String k_tag = ((TextView) view.findViewById(R.id.carres_k_tag_list)).getText().toString();
            String assistance = ((TextView) view.findViewById(R.id.carres_assistance_list)).getText()
                    .toString();
            String dinsurance = ((TextView) view.findViewById(R.id.carres_dinsurance_list)).getText()
                    .toString();
            String ainsurance = ((TextView) view.findViewById(R.id.carres_ainsurance_list)).getText()
                    .toString();
            String state = ((TextView) view.findViewById(R.id.carres_state_list)).getText().toString();
            String city = ((TextView) view.findViewById(R.id.carres_city_list)).getText().toString();
            String start_date = ((TextView) view.findViewById(R.id.carres_start_list)).getText().toString();
            String end_date = ((TextView) view.findViewById(R.id.carres_end_list)).getText().toString();
            String carid = ((TextView) view.findViewById(R.id.carres_id_list)).getText().toString();

            Intent ii = new Intent(getApplicationContext(), SalesCheckoutCar.class);

            ii.putExtra("carid", carid);
            ii.putExtra("state", state);
            ii.putExtra("city", city);
            ii.putExtra("start_date", start_date);
            ii.putExtra("end_date", end_date);
            ii.putExtra("gps", gps);
            ii.putExtra("child_seat", child_seat);
            ii.putExtra("ktag", k_tag);
            ii.putExtra("assistance", assistance);
            ii.putExtra("dinsurance", dinsurance);
            ii.putExtra("ainsurance", ainsurance);
            ii.putExtra("reservation", "1");
            ii.putExtra("email", userEmail);
            ii.putExtra("key", key);
            ii.putExtra("name", name);

            startActivity(ii);
            finish();
        }

    });
}

From source file:com.netpace.expressit.activity.UploadImageStoryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_upload_image_story);

    getSupportActionBar().setTitle("retake");
    getSupportActionBar().setDisplayShowHomeEnabled(false);

    Intent intent = getIntent();
    img_filePath = intent.getStringExtra(IMAGE_PATH);
    widthAfter = intent.getIntExtra(IMAGE_WIDTH, 0);
    heightAfter = intent.getIntExtra(IMAGE_HEIGHT, 0);
    isGalleryPhoto = intent.getBooleanExtra("isGalleryPhoto", false);

    imageViewThumbnail = (ImageView) findViewById(R.id.imageViewThumb);
    imageViewThumbnail.setImageURI(Uri.parse(img_filePath));
    titleTextView = (TypefaceEditText) findViewById(R.id.story_title_txt_field);

    button_saveLater = (Button) findViewById(R.id.shareButton);
    button_saveLater.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (isValidate()) {
                // close the keyboard.
                InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(titleTextView.getWindowToken(), 0);

                getMediaKeyFromRemoteServer();
            }//w  ww.  j  a  va 2  s  . co  m
        }
    });
}

From source file:com.messagesight.mqtthelper.PayloadViewer.java

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.payload);//  www .  j  av  a  2 s  .c om
    LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("payload"));
    expListView = (ExpandableListView) findViewById(R.id.expandableListView);

    Intent intent = getIntent();
    String jsonString = "";
    jsonString = intent.getStringExtra("json");

    // System.out.println("JSON Present: "+jsonString);
    headers = MqttHandler.getInstance().topicsReceived;
    listChildren = MqttHandler.getInstance().payload;
    payloadAdapter = new PayloadAdapter(this, headers, listChildren);
    expListView.setAdapter(payloadAdapter); //set adapter

    // populate the listView for JSONObject Payloads
    if (jsonString != null) {

        try {
            JSONObject json = new JSONObject(jsonString);

            tempHeaders = new ArrayList<String>();
            tempListChildren = new HashMap<String, List<String>>();
            // headers.clear();
            // listChildren.clear();

            Iterator<?> keys = json.keys();

            while (keys.hasNext()) {
                String key = (String) keys.next();

                tempHeaders.add(key);

                List<String> val = new ArrayList<String>();
                val.add(json.get(key).toString());
                tempListChildren.put(key, val);
            }

            payloadAdapter = new PayloadAdapter(this, tempHeaders, tempListChildren);
            expListView.setAdapter(payloadAdapter);
            isJsonView = true;

        } catch (JSONException e) {

        }
    }

    // Listview on child click listener
    expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            // TODO Auto-generated method stub
            List<String> tempHeadersOnClick;
            HashMap<String, List<String>> tempListChildrenOnClick;
            if (isJsonView) {
                tempHeadersOnClick = tempHeaders;
                tempListChildrenOnClick = tempListChildren;
            } else {
                tempHeadersOnClick = headers;
                tempListChildrenOnClick = listChildren;

            }

            JSONObject json = null;
            try {
                json = new JSONObject(
                        tempListChildrenOnClick.get(tempHeadersOnClick.get(groupPosition)).get(childPosition));
            } catch (JSONException e) {

            }

            if (json != null) {
                Intent intent = new Intent(getApplicationContext(), PayloadViewer.class);
                intent.putExtra("json", json.toString());
                startActivity(intent);
            }
            return false;
        }
    });

}