Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

In this page you can find the example usage for android.os Bundle get.

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:com.archer.circle_run.util.IabHelper.java

int getResponseCodeFromBundle(Bundle b) {
    Object o = null;/* www . j a  v  a  2s .  c o m*/
    if (b != null)
        o = b.get(RESPONSE_CODE);
    if (o == null) {
        logDebug("Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer)
        return ((Integer) o).intValue();
    else if (o instanceof Long)
        return (int) ((Long) o).longValue();
    else {
        logError("Unexpected type for bundle response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:com.example.igorklimov.tictactoe.wifi.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);

    if (extras != null && !extras.isEmpty()) { // has effect of unparcelling Bundle
        // Since we're not using two way messaging, this is all we really to check for
        if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            Logger.getLogger("GCM_RECEIVED").log(Level.INFO, extras.toString());

            String action = extras.getString(ACTION);
            String message = "";

            if (action == null) {
                return;
            }//from  w  w w  .ja va  2s.co m

            if (action.equals(INVITE_TO_PLAY)) {
                message = getApplicationContext().getString(R.string.format_invite_to_play, extras.get(NAME));
            } else if (action.equals(NEW_USER)) {
                message = getApplicationContext().getString(R.string.new_user, extras.get(NAME));
            } else if (action.equals(START_GAME)) {
                message = getApplicationContext().getString(R.string.start_game);
            }
            showToast(message);
            //                sendNotification(message);
        }
    }
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:babybear.akbquiz.ConfigActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQUESTCODE_IMAGE) {
        if (resultCode == RESULT_OK) {
            Bundle d = data.getExtras();
            Set<String> keys = d.keySet();
            for (String key : keys) {
                Log.d(TAG, "key : " + key + " values : " + d.get(key));
            }/* w w  w.j a v a  2  s  . co  m*/
            cfgEditor.putBoolean(Database.KEY_use_custom_background, true);
            cfgEditor.commit();
            cfgflipper.setBackgroundDrawable(Drawable.createFromPath(customBgImage.getPath()));
        }
        return;
    }

    if (weiboSsoHandler != null) {
        weiboSsoHandler.authorizeCallBack(requestCode, resultCode, data);
    }
}

From source file:com.trukr.shipper.fragment.RequestStatus.java

private void readOrder() {
    pd = new ProgressDialog(mContext, android.app.AlertDialog.THEME_DEVICE_DEFAULT_LIGHT);
    pd.setMessage("Loading...");
    pd.setCancelable(false);//ww w . j a va 2s.com
    pd.show();
    // Get the value of orderId from intent get
    try {
        Intent iin = getIntent();
        Bundle b = iin.getExtras();
        if (b != null) {
            orderId = (String) b.get("OrderId");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    queue = Volley.newRequestQueue(mContext);
    JSONObject object = null;
    try {
        object = new JSONObject();
        object.put("UserType", IConstant.UserType);
        object.put("UserId", userId);
        object.put("AuthToken", authToken);
        object.put("OrderId", orderId);
        System.out.println("readputparams-------->" + userId + authToken + orderId);
    } catch (JSONException e1) {
        e1.printStackTrace();
    }
    JsonObjectRequest request = new JsonObjectRequest(Request.Method.POST, IConstant.ReadShipment, object,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.d("Test", response.toString());
                    closeprogress();
                    try {
                        int StatusCode = Integer.parseInt(response.getString("StatusCode"));
                        String Message = response.getString("Message");
                        if (StatusCode == 97) {
                            TrukrApplication.unauthorisedAlertDialog(mContext, IConstant.alert, Message);
                        }
                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    try {
                        if (response.getString("Message").equals("Success")) {
                            orderNo = response.getString("OrderId");
                            orderStatus = response.getString("OrderStatus");
                            tv_orderStatus.setText(orderStatus);
                            JSONObject shipment = response.getJSONObject("Shipment");
                            JSONObject source = shipment.getJSONObject("Source");
                            JSONObject destination = shipment.getJSONObject("Destination");
                            fromAdd = source.getString("FromAddress");
                            toAdd = destination.getString("ToAddress");
                            String fromlat = source.getString("FromLatitude");
                            String fromlon = source.getString("FromLongitude");
                            String tolat = destination.getString("ToLatitude");
                            String tolon = destination.getString("ToLongitude");

                            preferences = getSharedPreferences("Details", MODE_PRIVATE);
                            editor = preferences.edit();
                            editor.putString("FromAddress", fromAdd);
                            editor.putString("FromLatitude", fromlat);
                            editor.putString("FromLongitude", fromlon);
                            editor.putString("ToAddress", toAdd);
                            editor.putString("ToLatitude", tolat);
                            editor.putString("ToLongitude", tolon);
                            editor.commit();

                            JSONObject driver = response.getJSONObject("Driver");
                            driversname = driver.getString("DriverName");
                            driverContactValue = driver.getString("DriverContact");
                            driverLicenseValue = driver.getString("DriverLicense");
                            driverUsDotNumberValue = driver.getString("USDotNumber");
                            driverMcNumberValue = driver.getString("MCNumber");
                            driverLicensePlatesValue = driver.getString("LicensePlates");
                            truckSafetyRatingValue = driver.getString("TruckSafetyRating");
                            insuranceValue = driver.getString("Insurance");
                            driverImage = driver.getString("DriverImage");
                            System.out.println("DriverDetai--->" + driversname + driverContactValue
                                    + driverLicenseValue + driverUsDotNumberValue + driverMcNumberValue);
                            tv_drivername.setText(driversname);
                            try {
                                Picasso.with(getApplicationContext()).load(driverImage).into(driverProfile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                            System.out.println(fromAdd.toString() + toAdd.toString());
                            System.out.println(fromlat.toString() + fromlon.toString());
                            System.out.println(tolat.toString() + tolon.toString());
                            latstart = Double.parseDouble(fromlat);
                            latEnd = Double.parseDouble(tolat);
                            longStart = Double.parseDouble(fromlon);
                            longEnd = Double.parseDouble(tolon);
                            System.out.println("Directions----->" + latstart + latEnd + longStart + longEnd);

                            if (map == null) {
                                map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
                                // check if map is created successfully or not
                                if (map == null) {
                                    Toast.makeText(RequestStatus.this, "Sorry! unable to create maps",
                                            Toast.LENGTH_SHORT).show();
                                }
                            }
                            //   map.addMarker(new MarkerOptions().position(new LatLng(latstart, longStart))/*.title("Marker in Pondy")*/.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_icon)).title(fromAdd));
                            map.animateCamera(
                                    CameraUpdateFactory.newLatLngZoom(new LatLng(latstart, longStart), 7));
                            map.animateCamera(CameraUpdateFactory.zoomTo(7));
                            String url = getDirectionsUrl();
                            // Start downloading json data from Google Directions API
                            DownloadTask downloadTask = new DownloadTask();
                            downloadTask.execute(url);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    closeprogress();
                    Log.d("Response: ", error.toString());
                    String json;
                    if (error.networkResponse != null && error.networkResponse.data != null) {
                        try {
                            json = new String(error.networkResponse.data,
                                    HttpHeaderParser.parseCharset(error.networkResponse.headers));
                            Log.e("Error list-->", json);
                            try {
                                //  Parsing json object response response will be a json object
                                if (json != null) {
                                    JSONObject jsonObject = new JSONObject(json);
                                    String message = jsonObject.getString("message");
                                    Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG).show();
                                    AlertDialog.Builder dlgAlert = new AlertDialog.Builder(
                                            getApplicationContext());
                                    dlgAlert.setMessage(message);
                                    dlgAlert.setTitle("Login ");
                                    dlgAlert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int which) {
                                            //dismiss the dialog
                                            dialog.dismiss();
                                        }
                                    });
                                    dlgAlert.setCancelable(true);
                                    dlgAlert.create().show();
                                }
                            } catch (JSONException e) {
                                e.printStackTrace();
                                Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(),
                                        Toast.LENGTH_LONG).show();
                            }
                        } catch (UnsupportedEncodingException e) {
                            Log.e("Error 111", e.getMessage());
                        }
                    }
                }
            });
    // volley time out error
    request.setRetryPolicy(new DefaultRetryPolicy(500000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    queue.add(request);
}

From source file:com.facebook.share.ShareApi.java

private void stageOpenGraphAction(final Bundle parameters,
        final CollectionMapper.OnMapperCompleteListener onOpenGraphActionStagedListener) {
    final CollectionMapper.Collection<String> collection = new CollectionMapper.Collection<String>() {
        @Override/*from   w w w.ja v a2s.c o m*/
        public Iterator<String> keyIterator() {
            return parameters.keySet().iterator();
        }

        @Override
        public Object get(String key) {
            return parameters.get(key);
        }

        @Override
        public void set(String key, Object value, CollectionMapper.OnErrorListener onErrorListener) {
            if (!Utility.putJSONValueInBundle(parameters, key, value)) {
                onErrorListener.onError(new FacebookException("Unexpected value: " + value.toString()));
            }
        }
    };
    stageCollectionValues(collection, onOpenGraphActionStagedListener);
}

From source file:de.geithonline.abattlwp.billinghelper.IabHelper.java

int getResponseCodeFromBundle(final Bundle b) {
    final Object o = b.get(RESPONSE_CODE);
    if (o == null) {
        logDebug("Bundle with null response code, assuming OK (known issue)");
        return BILLING_RESPONSE_RESULT_OK;
    } else if (o instanceof Integer) {
        return ((Integer) o).intValue();
    } else if (o instanceof Long) {
        return (int) ((Long) o).longValue();
    } else {//  w w w  .ja v a2s.  c  o  m
        logError("Unexpected type for bundle response code.");
        logError(o.getClass().getName());
        throw new RuntimeException("Unexpected type for bundle response code: " + o.getClass().getName());
    }
}

From source file:org.deviceconnect.android.deviceplugin.host.activity.CanvasProfileActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_canvas_profile);

    mCanvasView = (ImageView) findViewById(R.id.canvasProfileView);

    Button btn = (Button) findViewById(R.id.buttonClose);
    btn.setOnClickListener(new OnClickListener() {
        @Override/* www .j  a  v  a  2 s.c  o  m*/
        public void onClick(final View v) {
            finish();
        }
    });

    Intent intent = null;
    if (savedInstanceState != null) {
        intent = (Intent) savedInstanceState.get(PARAM_INTENT);
    }
    if (intent == null) {
        intent = getIntent();
    }
    setDrawingArgument(intent);
}

From source file:edu.pdx.cs410.wifi.direct.file.transfer.ClientActivity.java

public void sendFile(View view) {

    //Only try to send file if there isn't already a transfer active
    if (!transferActive) {
        if (!filePathProvided) {
            setClientFileTransferStatus("Select a file to send before pressing send");
        } else if (!connectedAndReadyToSendFile) {
            setClientFileTransferStatus("You must be connected to a server before attempting to send a file");
        }//from  w  w w .  j  a v a  2s  .  c  o  m
        /*
        else if(targetDevice == null)
        {
           setClientFileTransferStatus("Target Device network information unknown");
        }
        */
        else if (wifiInfo == null) {
            setClientFileTransferStatus("Missing Wifi P2P information");
        } else {
            //Launch client service
            clientServiceIntent = new Intent(this, ClientService.class);
            clientServiceIntent.putExtra("fileToSend", fileToSend);
            clientServiceIntent.putExtra("port", new Integer(port));
            //clientServiceIntent.putExtra("targetDevice", targetDevice);
            clientServiceIntent.putExtra("wifiInfo", wifiInfo);
            clientServiceIntent.putExtra("clientResult", new ResultReceiver(null) {
                @Override
                protected void onReceiveResult(int resultCode, final Bundle resultData) {

                    if (resultCode == port) {
                        if (resultData == null) {
                            //Client service has shut down, the transfer may or may not have been successful. Refer to message 
                            transferActive = false;
                        } else {
                            final TextView client_status_text = (TextView) findViewById(
                                    R.id.file_transfer_status);

                            client_status_text.post(new Runnable() {
                                public void run() {
                                    client_status_text.setText((String) resultData.get("message"));
                                }
                            });
                        }
                    }

                }
            });

            transferActive = true;
            startService(clientServiceIntent);

            //end
        }
    }
}

From source file:edu.nust.distributed.downloader.ClientActivity.java

public void sendFile(View view) {

    //Only try to send file if there isn't already a transfer active
    if (!transferActive) {

        if (!connectedAndReadyToSendFile) {
            setClientFileTransferStatus("You must be connected to a server before attempting to send a file");
        }//w  w w.j av a  2 s . c om
        /*
        else if(targetDevice == null)
        {
           setClientFileTransferStatus("Target Device network information unknown");
        }
        */
        else if (wifiInfo == null) {
            setClientFileTransferStatus("Missing Wifi P2P information");
        } else {
            //Launch client service
            clientServiceIntent = new Intent(this, ClientService.class);
            TextView location = (TextView) (TextView) findViewById(R.id.textView);
            clientServiceIntent.putExtra("fileToSend", location.getText());
            clientServiceIntent.putExtra("port", new Integer(port));
            //clientServiceIntent.putExtra("targetDevice", targetDevice);
            clientServiceIntent.putExtra("wifiInfo", wifiInfo);
            clientServiceIntent.putExtra("clientResult", new ResultReceiver(null) {
                @Override
                protected void onReceiveResult(int resultCode, final Bundle resultData) {

                    if (resultCode == port) {
                        if (resultData == null) {
                            //Client service has shut down, the transfer may or may not have been successful. Refer to message 
                            transferActive = false;
                        } else {
                            final TextView client_status_text = (TextView) findViewById(
                                    R.id.file_transfer_status);

                            client_status_text.post(new Runnable() {
                                public void run() {
                                    client_status_text.setText((String) resultData.get("message"));
                                }
                            });
                        }
                    }

                }
            });

            transferActive = true;
            startService(clientServiceIntent);

            //end
        }
    }
}

From source file:com.blogspot.marioboehmer.thingibrowse.fragments.ThingResultListFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    thingListAdapter = new ThingListAdapter(getActivity());
    setListAdapter(thingListAdapter);// w ww  .  j  a  va  2s.co m
    if (savedInstanceState == null) {
        if (thingCategoryBaseUrl == null) {
            thingCategoryBaseUrl = getResources().getStringArray(R.array.things_category_base_urls)[0];
        }
        loadThingResults(currentPage);
    } else {
        currentPage = savedInstanceState.getInt(CURRENT_PAGE);
        lastPageIndex = savedInstanceState.getInt(LAST_PAGE_INDEX);
        thingCategoryBaseUrl = savedInstanceState.getString(THING_CATEGORY_BASE_URL);
        isSearchResultList = savedInstanceState.getBoolean(IS_SEARCH);
        searchTerm = savedInstanceState.getString(SEARCH_TERM);
        updateView((ArrayList<ThingResultListItem>) savedInstanceState.get(THING_RESULT_LIST), true);
    }
}