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.phonegap.DroidGap.java

/**
 * Get boolean property for activity.//from   ww w  .j ava  2s.  c o m
 * 
 * @param name
 * @param defaultValue
 * @return
 */
public boolean getBooleanProperty(String name, boolean defaultValue) {
    Bundle bundle = this.getIntent().getExtras();
    if (bundle == null) {
        return defaultValue;
    }
    Boolean p = (Boolean) bundle.get(name);
    if (p == null) {
        return defaultValue;
    }
    return p.booleanValue();
}

From source file:com.phonegap.DroidGap.java

/**
 * Get int property for activity.//w ww. ja va 2  s.  co m
 * 
 * @param name
 * @param defaultValue
 * @return
 */
public int getIntegerProperty(String name, int defaultValue) {
    Bundle bundle = this.getIntent().getExtras();
    if (bundle == null) {
        return defaultValue;
    }
    Integer p = (Integer) bundle.get(name);
    if (p == null) {
        return defaultValue;
    }
    return p.intValue();
}

From source file:com.cwp.cmoneycharge.activity.AddPayActivity.java

@Override
public void onEvent(int eventType, Bundle params) {
    //?/*from ww  w. java  2  s .com*/
    switch (eventType) {
    case EVENT_ERROR:
        String reason = params.get("reason") + "";
        Log.d("Add", "EVENT_ERROR, " + reason);
        break;
    case VoiceRecognitionService.EVENT_ENGINE_SWITCH:
        int type = params.getInt("engine_type");
        Log.d("Add", "*?" + (type == 0 ? "" : ""));
        break;
    }
}

From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.track.TrackListingFragment.java

private List<TrackObject> getTracks(AbstractLstingFragment.ListingRequest... params) {
    try {/* w  w  w . ja  v a2  s.c  om*/
        Collection<TrackObjectForBean> result = null;
        List<TrackObject> returnArray = new ArrayList<TrackObject>();
        Bundle bundle = getArguments();
        boolean my = false;
        if (bundle.getBoolean(SearchFragment.ARG_MY))
            my = true;
        String categories = bundle.getString(SearchFragment.ARG_CATEGORY);
        String query = bundle.getString(SearchFragment.ARG_QUERY);

        SortedMap<String, Integer> sort = new TreeMap<String, Integer>();
        sort.put("title", 1);

        if (categories != null || my || query != null) {
            result = DTHelper.searchInGeneral(params[0].position, params[0].size, query,
                    (WhereForSearch) bundle.getParcelable(SearchFragment.ARG_WHERE_SEARCH),
                    (WhenForSearch) bundle.getParcelable(SearchFragment.ARG_WHEN_SEARCH), my,
                    TrackObjectForBean.class, sort, categories);
        } else if (bundle.containsKey(SearchFragment.ARG_LIST)) {
            return (List<TrackObject>) bundle.get(SearchFragment.ARG_LIST);
        } else {
            return Collections.emptyList();
        }

        for (TrackObjectForBean trackBean : result) {
            returnArray.add(trackBean.getObjectForBean());
        }
        return returnArray;
    } catch (Exception e) {
        Log.e(TrackListingFragment.class.getName(), e.getMessage());
        e.printStackTrace();
        return Collections.emptyList();
    }
}

From source file:com.tealeaf.TeaLeaf.java

protected void onActivityResult(int request, int result, Intent data) {
    super.onActivityResult(request, result, data);
    PluginManager.callAll("onActivityResult", request, result, data);
    logger.log("GOT ACTIVITY RESULT WITH", request, result);

    switch (request) {
    case PhotoPicker.CAPTURE_IMAGE:
        if (result == RESULT_OK) {
            EventQueue.pushEvent(new PhotoBeginLoadedEvent());
            Bitmap bmp = null;//from   w w w.  j  a va  2 s  .co  m

            if (data != null) {
                Bundle extras = data.getExtras();
                //try and get bitmap off of intent
                if (extras != null) {
                    bmp = (Bitmap) extras.get("data");
                }

            }

            //try the large file on disk
            final File f = PhotoPicker.getCaptureImageTmpFile();
            if (f != null && f.exists()) {
                new Thread(new Runnable() {
                    public void run() {
                        Bitmap bmp = null;
                        String filePath = f.getAbsolutePath();

                        try {
                            bmp = BitmapFactory.decodeFile(filePath);
                        } catch (OutOfMemoryError e) {
                            System.gc();
                            BitmapFactory.Options options = new BitmapFactory.Options();
                            options.inSampleSize = 4;
                            bmp = BitmapFactory.decodeFile(filePath, options);
                        }

                        if (bmp != null) {
                            try {
                                File f = new File(filePath);
                                ExifInterface exif = new ExifInterface(f.getAbsolutePath());
                                int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                                        ExifInterface.ORIENTATION_NORMAL);
                                if (orientation != ExifInterface.ORIENTATION_NORMAL) {
                                    int rotateBy = 0;
                                    switch (orientation) {
                                    case ExifInterface.ORIENTATION_ROTATE_90:
                                        rotateBy = ROTATE_90;
                                        break;
                                    case ExifInterface.ORIENTATION_ROTATE_180:
                                        rotateBy = ROTATE_180;
                                        break;
                                    case ExifInterface.ORIENTATION_ROTATE_270:
                                        rotateBy = ROTATE_270;
                                        break;
                                    }
                                    Bitmap rotatedBmp = rotateBitmap(bmp, rotateBy);
                                    if (rotatedBmp != bmp) {
                                        bmp.recycle();
                                    }
                                    bmp = rotatedBmp;
                                }
                            } catch (Exception e) {
                                logger.log(e);
                            }
                            f.delete();

                            if (bmp != null) {
                                glView.getTextureLoader()
                                        .saveCameraPhoto(glView.getTextureLoader().getCurrentPhotoId(), bmp);
                                glView.getTextureLoader().finishCameraPicture();
                            } else {
                                glView.getTextureLoader().failedCameraPicture();
                            }
                        }
                    }
                }).start();

            } else {
                glView.getTextureLoader().saveCameraPhoto(glView.getTextureLoader().getCurrentPhotoId(), bmp);
                glView.getTextureLoader().finishCameraPicture();
            }
        } else {
            glView.getTextureLoader().failedCameraPicture();
        }
        break;
    case PhotoPicker.PICK_IMAGE:
        if (result == RESULT_OK) {
            final Uri selectedImage = data.getData();
            EventQueue.pushEvent(new PhotoBeginLoadedEvent());

            String[] filePathColumn = { MediaColumns.DATA, MediaStore.Images.ImageColumns.ORIENTATION };

            String _filepath = null;

            try {
                Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                _filepath = cursor.getString(columnIndex);
                columnIndex = cursor.getColumnIndex(filePathColumn[1]);
                int orientation = cursor.getInt(columnIndex);
                cursor.close();
            } catch (Exception e) {

            }

            final String filePath = _filepath;

            new Thread(new Runnable() {
                public void run() {
                    if (filePath == null) {
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        InputStream inputStream;
                        Bitmap bmp = null;

                        try {
                            inputStream = getContentResolver().openInputStream(selectedImage);
                            bmp = BitmapFactory.decodeStream(inputStream, null, options);
                            inputStream.close();
                        } catch (Exception e) {
                            logger.log(e);

                        }

                        if (bmp != null) {
                            glView.getTextureLoader()
                                    .saveGalleryPicture(glView.getTextureLoader().getCurrentPhotoId(), bmp);
                            glView.getTextureLoader().finishGalleryPicture();
                        } else {
                            glView.getTextureLoader().failedGalleryPicture();
                        }

                    } else {
                        Bitmap bmp = null;

                        try {
                            bmp = BitmapFactory.decodeFile(filePath);
                        } catch (OutOfMemoryError e) {
                            System.gc();
                            BitmapFactory.Options options = new BitmapFactory.Options();
                            options.inSampleSize = 4;
                            bmp = BitmapFactory.decodeFile(filePath, options);
                        }

                        if (bmp != null) {
                            try {
                                File f = new File(filePath);
                                ExifInterface exif = new ExifInterface(f.getAbsolutePath());
                                int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                                        ExifInterface.ORIENTATION_NORMAL);
                                if (orientation != ExifInterface.ORIENTATION_NORMAL) {
                                    int rotateBy = 0;
                                    switch (orientation) {
                                    case ExifInterface.ORIENTATION_ROTATE_90:
                                        rotateBy = ROTATE_90;
                                        break;
                                    case ExifInterface.ORIENTATION_ROTATE_180:
                                        rotateBy = ROTATE_180;
                                        break;
                                    case ExifInterface.ORIENTATION_ROTATE_270:
                                        rotateBy = ROTATE_270;
                                        break;
                                    }
                                    Bitmap rotatedBmp = rotateBitmap(bmp, rotateBy);
                                    if (rotatedBmp != bmp) {
                                        bmp.recycle();
                                    }
                                    bmp = rotatedBmp;
                                }
                            } catch (Exception e) {
                                logger.log(e);
                            }

                            if (bmp != null) {
                                glView.getTextureLoader()
                                        .saveGalleryPicture(glView.getTextureLoader().getCurrentPhotoId(), bmp);
                                glView.getTextureLoader().finishGalleryPicture();
                            } else {
                                glView.getTextureLoader().failedGalleryPicture();
                            }
                        }
                    }
                }
            }).start();

        } else {
            glView.getTextureLoader().failedGalleryPicture();
        }
        break;
    }
}

From source file:com.asb.spandan2014.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.isEmpty()) { // has effect of unparcelling Bundle
        /*/*from   w w w.ja  va2s. c  om*/
         * 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());
            // If it's a regular GCM message, do some work.
        } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) {
            // This loop represents the service doing some work.

            // Post notification of received message.
            String update = (String) extras.get("Update");
            String sender = (String) extras.get("Sender");
            sendNotification(sender + ": " + update);

            Log.i(TAG, "Received: " + extras.toString());
        }
    }
    // Release the wake lock provided by the WakefulBroadcastReceiver.
    GcmBroadcastReceiver.completeWakefulIntent(intent);
}

From source file:com.eleybourn.bookcatalogue.utils.Utils.java

/**
 * Format the passed bundle in a way that is convenient for display
 * //from  w  ww.j  a  v  a  2  s. c o m
 * @param b      Bundle to format
 * 
 * @return      Formatted string
 */
public static String bundleToString(Bundle b) {
    StringBuilder sb = new StringBuilder();
    for (String k : b.keySet()) {
        sb.append(k);
        sb.append("->");
        try {
            sb.append(b.get(k).toString());
        } catch (Exception e) {
            sb.append("<<Unknown>>");
        }
        sb.append("\n");
    }
    return sb.toString();
}

From source file:eu.janmuller.android.simplecropimage.CropImage.java

@Override
public void onCreate(Bundle icicle) {

    super.onCreate(icicle);
    mContentResolver = getContentResolver();

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.cropimage);/*from w  w w  .jav  a 2s .  com*/

    mImageView = (CropImageView) findViewById(R.id.image);

    showStorageToast(this);

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    if (extras != null) {

        if (extras.getString(CIRCLE_CROP) != null) {

            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
                mImageView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
            }

            mCircleCrop = true;
            mAspectX = 1;
            mAspectY = 1;
        }

        mImagePath = extras.getString(IMAGE_FILE);

        if (mImagePath == null) {
            mSaveUri = extras.getParcelable(IMAGE_PATH);
        } else {
            mSaveUri = getImageUri(mImagePath);
        }

        mBitmap = getBitmap(mSaveUri);

        if (extras.containsKey(ASPECT_X) && extras.get(ASPECT_X) instanceof Integer) {

            mAspectX = extras.getInt(ASPECT_X);
        } else {

            throw new IllegalArgumentException("aspect_x must be integer");
        }
        if (extras.containsKey(ASPECT_Y) && extras.get(ASPECT_Y) instanceof Integer) {

            mAspectY = extras.getInt(ASPECT_Y);
        } else {

            throw new IllegalArgumentException("aspect_y must be integer");
        }
        mOutputX = extras.getInt(OUTPUT_X);
        mOutputY = extras.getInt(OUTPUT_Y);
        mScale = extras.getBoolean(SCALE, true);
        mScaleUp = extras.getBoolean(SCALE_UP_IF_NEEDED, true);
    }

    if (mBitmap == null) {

        Log.d(TAG, "finish!!!");
        finish();
        return;
    }

    // Make UI fullscreen.
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    findViewById(R.id.discard).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            setResult(RESULT_CANCELED);
            finish();
        }
    });

    findViewById(R.id.save).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            try {
                onSaveClicked();
            } catch (Exception e) {
                finish();
            }
        }
    });
    /*findViewById(R.id.rotateLeft).setOnClickListener(
        new View.OnClickListener() {
            public void onClick(View v) {
            
                mBitmap = Util.rotateImage(mBitmap, -90);
                RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
                mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
                mRunFaceDetection.run();
            }
        });*/

    /*findViewById(R.id.rotateRight).setOnClickListener(
        new View.OnClickListener() {
            public void onClick(View v) {
            
                mBitmap = Util.rotateImage(mBitmap, 90);
                RotateBitmap rotateBitmap = new RotateBitmap(mBitmap);
                mImageView.setImageRotateBitmapResetBase(rotateBitmap, true);
                mRunFaceDetection.run();
            }
        });*/
    startFaceDetection();
}

From source file:com.canappi.connector.yp.yhere.CouponView.java

public void viewDidLoad() {

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        Set<String> keys = extras.keySet();
        for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
            String key = iter.next();
            Class c = SearchView.class;
            try {
                Field f = c.getDeclaredField(key);
                Object extra = extras.get(key);
                String value = extra.toString();
                f.set(this, extras.getString(value));
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();// w  w  w .j a  v  a 2  s.c o  m
            } catch (NoSuchFieldException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } else {

    }

    couponViewIds = new HashMap();
    couponViewValues = new HashMap();

    isUserDefault = false;

    resultsListView = (ListView) findViewById(R.id.resultsTable);
    resultsAdapter = new ResultsEfficientAdapter(this);

    businessNameArray = new ArrayList<String>();

    couponDescriptionArray = new ArrayList<String>();

    couponIdArray = new ArrayList<String>();

    phoneNumberArray = new ArrayList<String>();

    callArray = new ArrayList<String>();

    streetArray = new ArrayList<String>();

    cityArray = new ArrayList<String>();
    resultsListView.setAdapter(resultsAdapter);
    didSelectViewController();

}