Example usage for android.content Intent getParcelableExtra

List of usage examples for android.content Intent getParcelableExtra

Introduction

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

Prototype

public <T extends Parcelable> T getParcelableExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.grass.caishi.cc.activity.AdAddActivity.java

/**
 * onActivityResult//from  w w w .j  ava2  s  .  c om
 */
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK) { // ?
        if (requestCode == REQUEST_CODE_CAMERA) { // ??
            if (cameraFile != null && cameraFile.exists())
                if (select_type == 1)
                    cropImageUri(Uri.fromFile(cameraFile), 450, 150, USERPIC_REQUEST_CODE_CUT);
                else
                    addToListImage(cameraFile.getAbsolutePath());
            // img_list.add(cameraFile.getAbsolutePath());
        } else if (requestCode == REQUEST_CODE_IMAGES) { // ??
            if (data != null) {
                Uri selectedImage = data.getData();
                if (selectedImage != null) {
                    if (select_type == 1)
                        cropImageUri(selectedImage, 450, 150, USERPIC_REQUEST_CODE_CUT);
                    else
                        addToListImage(getPicByUri(selectedImage));
                    // img_list.add(getPicByUri(selectedImage));
                }
            }
        } else if (requestCode == USERPIC_REQUEST_CODE_CUT) {// ?
            // ?
            if (data != null) {
                Bitmap bitmap = data.getParcelableExtra("data");
                img_logo.setImageBitmap(bitmap);
                System.err.println(cameraFile.getAbsolutePath());
                cameraFile = saveJPGE_After(bitmap, cameraFile); //
                // ????
                addToListImage(cameraFile.getAbsolutePath());
            } else {

            }
        }
    }
}

From source file:com.google.example.eightbitartist.DrawingActivity.java

@Override
public void onActivityResult(int request, int response, Intent data) {
    super.onActivityResult(request, response, data);
    Log.i(TAG, "onActivityResult: code = " + request + ", response = " + response);

    // Coming back from resolving a sign-in request
    if (request == RC_SIGN_IN) {
        mSignInClicked = false;//from w w w .ja v a 2 s  .c o  m
        mResolvingConnectionFailure = false;
        if (response == RESULT_OK) {
            mGoogleApiClient.connect();
        } else {
            BaseGameUtils.showActivityResultError(this, request, response, R.string.sign_in_failed);
        }
    }

    // Coming back from a RealTime Multiplayer waiting room
    if (request == RC_WAITING_ROOM) {
        dismissSpinner();

        Room room = data.getParcelableExtra(Multiplayer.EXTRA_ROOM);
        if (response == RESULT_OK) {
            Log.d(TAG, "Waiting Room: Success");
            mRoom = room;
            startMatch();
        } else if (response == RESULT_CANCELED) {
            Log.d(TAG, "Waiting Room: Canceled");
            leaveRoom();
        } else if (response == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
            Log.d(TAG, "Waiting Room: Left Room");
            leaveRoom();
        } else if (response == GamesActivityResultCodes.RESULT_INVALID_ROOM) {
            Log.d(TAG, "Waiting Room: Invalid Room");
            leaveRoom();
        }
    }

    // We are coming back from the player selection UI, in preparation to start a match.
    if (request == RC_SELECT_PLAYERS) {
        if (response != Activity.RESULT_OK) {
            // user canceled
            Log.d(TAG, "onActivityResult: user canceled player selection.");
            return;
        }

        // Create a basic room configuration
        RoomConfig.Builder roomConfigBuilder = RoomConfig.builder(this).setMessageReceivedListener(this)
                .setRoomStatusUpdateListener(this);

        // Set the auto match criteria
        int minAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MIN_AUTOMATCH_PLAYERS, 0);
        int maxAutoMatchPlayers = data.getIntExtra(Multiplayer.EXTRA_MAX_AUTOMATCH_PLAYERS, 0);
        if (minAutoMatchPlayers > 0 || maxAutoMatchPlayers > 0) {
            Bundle autoMatchCriteria = RoomConfig.createAutoMatchCriteria(minAutoMatchPlayers,
                    maxAutoMatchPlayers, 0);
            roomConfigBuilder.setAutoMatchCriteria(autoMatchCriteria);
        }

        // Set the invitees
        final ArrayList<String> invitees = data.getStringArrayListExtra(Games.EXTRA_PLAYER_IDS);
        if (invitees != null && invitees.size() > 0) {
            roomConfigBuilder.addPlayersToInvite(invitees);
        }

        // Build the room and start the match
        showSpinner();
        Games.RealTimeMultiplayer.create(mGoogleApiClient, roomConfigBuilder.build());
    }
}

From source file:com.conferenceengineer.android.iosched.ui.tablet.SessionsSandboxMultiPaneActivity.java

private void routeIntent(Intent intent, boolean updateSurfaceOnly) {
    Uri uri = intent.getData();//from  w w  w  .ja  v  a 2  s  .c  o  m
    if (uri == null) {
        return;
    }

    if (intent.hasExtra(Intent.EXTRA_TITLE)) {
        setTitle(intent.getStringExtra(Intent.EXTRA_TITLE));
    }

    String mimeType = getContentResolver().getType(uri);

    if (ScheduleContract.Tracks.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load track details
        showFullUI(true);
        if (!updateSurfaceOnly) {
            // TODO: don't assume the URI will contain the track ID
            int defaultViewType = intent.getIntExtra(EXTRA_DEFAULT_VIEW_TYPE,
                    TracksDropdownFragment.VIEW_TYPE_SESSIONS);
            String selectedTrackId = ScheduleContract.Tracks.getTrackId(uri);
            loadTrackList(defaultViewType, selectedTrackId);
            onTrackSelected(selectedTrackId);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_TYPE.equals(mimeType)) {
        // Load a session list, hiding the tracks dropdown and the tabs
        mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            loadSessionList(uri, null);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load session details
        if (intent.hasExtra(EXTRA_MASTER_URI)) {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
            showFullUI(false);
            if (!updateSurfaceOnly) {
                loadSessionList((Uri) intent.getParcelableExtra(EXTRA_MASTER_URI),
                        ScheduleContract.Sessions.getSessionId(uri));
                loadSessionDetail(uri);
            }
        } else {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS; // prepare for onTrackInfo...
            showFullUI(true);
            if (!updateSurfaceOnly) {
                loadSessionDetail(uri);
                loadTrackInfoFromSessionUri(uri);
            }
        }

    }

    updateDetailBackground();
}

From source file:com.android.leanlauncher.LauncherModel.java

ShortcutInfo infoFromShortcutIntent(Context context, Intent data) {
    Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT);
    String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);

    if (intent == null) {
        // If the intent is null, we can't construct a valid ShortcutInfo, so we return null
        Log.e(TAG, "Can't construct ShorcutInfo with null intent");
        return null;
    }/*ww w.  j a  va  2s  .  co  m*/

    final ShortcutInfo info = new ShortcutInfo();

    // Only support intents for current user for now. Intents sent from other
    // users wouldn't get here without intent forwarding anyway.
    info.user = UserHandleCompat.myUserHandle();

    info.title = name;
    info.contentDescription = mUserManager.getBadgedLabelForUser(info.title.toString(), info.user);
    info.intent = intent;

    // cache the icon for shortcut
    mIconCache.getAppIcon(info);

    return info;
}

From source file:com.android.contacts.ContactSaveService.java

private void createRawContact(Intent intent) {
    String accountName = intent.getStringExtra(EXTRA_ACCOUNT_NAME);
    String accountType = intent.getStringExtra(EXTRA_ACCOUNT_TYPE);
    String dataSet = intent.getStringExtra(EXTRA_DATA_SET);
    List<ContentValues> valueList = intent.getParcelableArrayListExtra(EXTRA_CONTENT_VALUES);
    Intent callbackIntent = intent.getParcelableExtra(EXTRA_CALLBACK_INTENT);

    ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
    operations.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
            .withValue(RawContacts.ACCOUNT_NAME, accountName).withValue(RawContacts.ACCOUNT_TYPE, accountType)
            .withValue(RawContacts.DATA_SET, dataSet).build());

    int size = valueList.size();
    for (int i = 0; i < size; i++) {
        ContentValues values = valueList.get(i);
        values.keySet().retainAll(ALLOWED_DATA_COLUMNS);
        operations.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
                .withValueBackReference(Data.RAW_CONTACT_ID, 0).withValues(values).build());
    }//from w ww .j  a va  2  s  . com

    ContentResolver resolver = getContentResolver();
    ContentProviderResult[] results;
    try {
        results = resolver.applyBatch(ContactsContract.AUTHORITY, operations);
    } catch (Exception e) {
        throw new RuntimeException("Failed to store new contact", e);
    }

    Uri rawContactUri = results[0].uri;
    callbackIntent.setData(RawContacts.getContactLookupUri(resolver, rawContactUri));

    deliverCallback(callbackIntent);
}

From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuService.java

@Override
protected void onHandleIntent(final Intent intent) {
    final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    // In order to let DfuActivity know whether DFU is in progress, we have to use Shared Preferences 
    final SharedPreferences.Editor editor = preferences.edit();
    editor.putBoolean(PREFS_DFU_IN_PROGRESS, true);
    editor.commit();/*from   w w  w . j a v  a 2 s.c  o  m*/

    initialize();

    final String deviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS);
    final String deviceName = intent.getStringExtra(EXTRA_DEVICE_NAME);
    final String filePath = intent.getStringExtra(EXTRA_FILE_PATH);
    final Uri fileUri = intent.getParcelableExtra(EXTRA_FILE_URI);
    final Uri logUri = intent.getParcelableExtra(EXTRA_LOG_URI);
    mLogSession = Logger.openSession(this, logUri);

    mDeviceAddress = deviceAddress;
    mDeviceName = deviceName;
    mConnectionState = STATE_DISCONNECTED;

    // read preferences
    final boolean packetReceiptNotificationEnabled = preferences
            .getBoolean(SettingsFragment.SETTINGS_PACKET_RECEIPT_NOTIFICATION_ENABLED, true);
    final String value = preferences.getString(SettingsFragment.SETTINGS_NUMBER_OF_PACKETS,
            String.valueOf(SettingsFragment.SETTINGS_NUMBER_OF_PACKETS_DEFAULT));
    int numberOfPackets = SettingsFragment.SETTINGS_NUMBER_OF_PACKETS_DEFAULT;
    try {
        numberOfPackets = Integer.parseInt(value);
        if (numberOfPackets < 0 || numberOfPackets > 0xFFFF)
            numberOfPackets = SettingsFragment.SETTINGS_NUMBER_OF_PACKETS_DEFAULT;
    } catch (final NumberFormatException e) {
        numberOfPackets = SettingsFragment.SETTINGS_NUMBER_OF_PACKETS_DEFAULT;
    }
    if (!packetReceiptNotificationEnabled)
        numberOfPackets = 0;
    mPacketsBeforeNotification = numberOfPackets;

    sendLogBroadcast(Level.VERBOSE, "Starting DFU service");

    HexInputStream his = null;
    try {
        // Prepare data to send, calculate stream size
        try {
            sendLogBroadcast(Level.VERBOSE, "Opening file...");
            if (fileUri != null)
                his = openInputStream(fileUri);
            else
                his = openInputStream(filePath);

            mImageSizeInBytes = his.sizeInBytes();
            mImageSizeInPackets = his.sizeInPackets(MAX_PACKET_SIZE);
            mHexInputStream = his;
            sendLogBroadcast(Level.INFO, "Image file opened (" + mImageSizeInBytes + " bytes)");
        } catch (final FileNotFoundException e) {
            loge("An exception occured while opening file", e);
            sendErrorBroadcast(ERROR_FILE_NOT_FOUND);
            return;
        } catch (final IOException e) {
            loge("An exception occured while calculating file size", e);
            sendErrorBroadcast(ERROR_FILE_CLOSED);
            return;
        }

        // Let's connect to the device
        sendLogBroadcast(Level.VERBOSE, "Connecting to DFU target...");
        updateProgressNotification(PROGRESS_CONNECTING);

        final BluetoothGatt gatt = connect(deviceAddress);
        // Are we connected?
        if (mErrorState > 0) { // error occurred
            final int error = mErrorState & ~ERROR_CONNECTION_MASK;
            loge("An error occurred while connecting to the device:" + error);
            sendLogBroadcast(Level.ERROR,
                    String.format("Connection failed (0x%02X): %s", error, GattError.parse(error)));
            terminateConnection(gatt, mErrorState);
            return;
        }
        if (mAborted) {
            logi("Upload aborted");
            sendLogBroadcast(Level.WARNING, "Upload aborted");
            terminateConnection(gatt, PROGRESS_ABORTED);
            return;
        }

        // We have connected to DFU device and services are discoverer
        final BluetoothGattService dfuService = gatt.getService(DFU_SERVICE_UUID); // there was a case when the service was null. I don't know why
        if (dfuService == null) {
            loge("DFU service does not exists on the device");
            sendLogBroadcast(Level.WARNING, "Connected. DFU Service not found");
            terminateConnection(gatt, ERROR_SERVICE_NOT_FOUND);
            return;
        }
        final BluetoothGattCharacteristic controlPointCharacteristic = dfuService
                .getCharacteristic(DFU_CONTROL_POINT_UUID);
        final BluetoothGattCharacteristic packetCharacteristic = dfuService.getCharacteristic(DFU_PACKET_UUID);
        if (controlPointCharacteristic == null || packetCharacteristic == null) {
            loge("DFU characteristics not found in the DFU service");
            sendLogBroadcast(Level.WARNING, "Connected. DFU Characteristics not found");
            terminateConnection(gatt, ERROR_CHARACTERISTICS_NOT_FOUND);
            return;
        }

        sendLogBroadcast(Level.INFO, "Connected. Services discovered");
        try {
            // enable notifications
            updateProgressNotification(PROGRESS_STARTING);
            setCharacteristicNotification(gatt, controlPointCharacteristic, true);
            sendLogBroadcast(Level.INFO, "Notifications enabled");

            try {
                // set up the temporary variable that will hold the responses
                byte[] response = null;

                // send Start DFU command to Control Point
                logi("Sending Start DFU command (Op Code = 1)");
                writeOpCode(gatt, controlPointCharacteristic, OP_CODE_START_DFU);
                sendLogBroadcast(Level.INFO, "DFU Start sent (Op Code 1) ");

                // send image size in bytes to DFU Packet
                logi("Sending image size in bytes to DFU Packet");
                writeImageSize(gatt, packetCharacteristic, mImageSizeInBytes);
                sendLogBroadcast(Level.INFO, "Firmware image size sent");

                // a notification will come with confirmation. Let's wait for it a bit
                response = readNotificationResponse();

                /*
                 * The response received from the DFU device contains:
                 * +---------+--------+----------------------------------------------------+
                 * | byte no |  value |                  description                       |
                 * +---------+--------+----------------------------------------------------+
                 * |       0 |     16 | Response code                                      |
                 * |       1 |      1 | The Op Code of a request that this response is for |
                 * |       2 | STATUS | See DFU_STATUS_* for status codes                  |
                 * +---------+--------+----------------------------------------------------+
                 */
                int status = getStatusCode(response, OP_CODE_RECEIVE_START_DFU_KEY);
                sendLogBroadcast(Level.INFO,
                        "Responce received (Op Code: " + response[1] + " Status: " + status + ")");
                if (status != DFU_STATUS_SUCCESS)
                    throw new RemoteDfuException("Starting DFU failed", status);

                // Send the number of packets of firmware before receiving a receipt notification
                final int numberOfPacketsBeforeNotification = mPacketsBeforeNotification;
                if (numberOfPacketsBeforeNotification > 0) {
                    logi("Sending the number of packets before notifications (Op Code = 8)");
                    setNumberOfPackets(OP_CODE_PACKET_RECEIPT_NOTIF_REQ, numberOfPacketsBeforeNotification);
                    writeOpCode(gatt, controlPointCharacteristic, OP_CODE_PACKET_RECEIPT_NOTIF_REQ);
                    sendLogBroadcast(Level.INFO, "Packet Receipt Notif Req (Op Code 8) sent (value: "
                            + mPacketsBeforeNotification + ")");
                }

                // Initialize firmware upload
                logi("Sending Receive Firmware Image request (Op Code = 3)");
                writeOpCode(gatt, controlPointCharacteristic, OP_CODE_RECEIVE_FIRMWARE_IMAGE);
                sendLogBroadcast(Level.INFO, "Receive Firmware Image request sent");

                // This allow us to calculate upload time
                final long startTime = System.currentTimeMillis();
                updateProgressNotification();
                try {
                    sendLogBroadcast(Level.INFO, "Starting upload...");
                    response = uploadFirmwareImage(gatt, packetCharacteristic, his);
                } catch (final DeviceDisconnectedException e) {
                    loge("Disconnected while sending data");
                    throw e;
                    // TODO reconnect?
                }

                final long endTime = System.currentTimeMillis();
                logi("Transfer of " + mBytesSent + " bytes has taken " + (endTime - startTime) + " ms");
                sendLogBroadcast(Level.INFO, "Upload completed in " + (endTime - startTime) + " ms");

                // Check the result of the operation
                status = getStatusCode(response, OP_CODE_RECEIVE_FIRMWARE_IMAGE_KEY);
                sendLogBroadcast(Level.INFO,
                        "Responce received (Op Code: " + response[1] + " Status: " + status + ")");
                logi("Response received. Op Code: " + response[0] + " Req Op Code: " + response[1] + " status: "
                        + response[2]);
                if (status != DFU_STATUS_SUCCESS)
                    throw new RemoteDfuException("Device returned error after sending file", status);

                // Send Validate request
                logi("Sending Validate request (Op Code = 4)");
                writeOpCode(gatt, controlPointCharacteristic, OP_CODE_VALIDATE);
                sendLogBroadcast(Level.INFO, "Validate request sent");

                // A notification will come with status code. Let's wait for it a bit.
                response = readNotificationResponse();
                status = getStatusCode(response, OP_CODE_RECEIVE_VALIDATE_KEY);
                sendLogBroadcast(Level.INFO,
                        "Responce received (Op Code: " + response[1] + " Status: " + status + ")");
                if (status != DFU_STATUS_SUCCESS)
                    throw new RemoteDfuException("Device returned validation error", status);

                // Disable notifications locally (we don't need to disable them on the device, it will reset)
                updateProgressNotification(PROGRESS_DISCONNECTING);
                gatt.setCharacteristicNotification(controlPointCharacteristic, false);
                sendLogBroadcast(Level.INFO, "Notifications disabled");

                // Send Activate and Reset signal.
                logi("Sending Activate and Reset request (Op Code = 5)");
                writeOpCode(gatt, controlPointCharacteristic, OP_CODE_ACTIVATE_AND_RESET);
                sendLogBroadcast(Level.INFO, "Activate and Reset request sent");

                // The device will reset so we don't have to send Disconnect signal.
                waitUntilDisconnected();
                sendLogBroadcast(Level.INFO, "Disconnected by remote device");

                // Close the device
                refreshDeviceCache(gatt);
                close(gatt);
                updateProgressNotification(PROGRESS_COMPLETED);
            } catch (final UnknownResponseException e) {
                final int error = ERROR_INVALID_RESPONSE;
                loge(e.getMessage());
                sendLogBroadcast(Level.ERROR, e.getMessage());

                // This causes GATT_ERROR 0x85 on Nexus 4 (4.4.2)
                //               logi("Sending Reset command (Op Code = 6)");
                //               writeOpCode(gatt, controlPointCharacteristic, OP_CODE_RESET);
                //               sendLogBroadcast(Level.INFO, "Reset request sent");
                terminateConnection(gatt, error);
            } catch (final RemoteDfuException e) {
                final int error = ERROR_REMOTE_MASK | e.getErrorNumber();
                loge(e.getMessage());
                sendLogBroadcast(Level.ERROR, String.format("Remote DFU error: %s", GattError.parse(error)));

                // This causes GATT_ERROR 0x85 on Nexus 4 (4.4.2)
                //               logi("Sending Reset command (Op Code = 6)");
                //               writeOpCode(gatt, controlPointCharacteristic, OP_CODE_RESET);
                //               sendLogBroadcast(Level.INFO, "Reset request sent");
                terminateConnection(gatt, error);
            }
        } catch (final UploadAbortedException e) {
            logi("Upload aborted");
            sendLogBroadcast(Level.WARNING, "Upload aborted");
            if (mConnectionState == STATE_CONNECTED_AND_READY)
                try {
                    mAborted = false;
                    logi("Sending Reset command (Op Code = 6)");
                    writeOpCode(gatt, controlPointCharacteristic, OP_CODE_RESET);
                    sendLogBroadcast(Level.INFO, "Reset request sent");
                } catch (final Exception e1) {
                    // do nothing
                }
            terminateConnection(gatt, PROGRESS_ABORTED);
        } catch (final DeviceDisconnectedException e) {
            sendLogBroadcast(Level.ERROR, "Device has disconneted");
            // TODO reconnect n times?
            loge(e.getMessage());
            if (mNotificationsEnabled)
                gatt.setCharacteristicNotification(controlPointCharacteristic, false);
            close(gatt);
            updateProgressNotification(ERROR_DEVICE_DISCONNECTED);
            return;
        } catch (final DfuException e) {
            final int error = e.getErrorNumber() & ~ERROR_CONNECTION_MASK;
            sendLogBroadcast(Level.ERROR, String.format("Error (0x%02X): %s", error, GattError.parse(error)));
            loge(e.getMessage());
            if (mConnectionState == STATE_CONNECTED_AND_READY)
                try {
                    logi("Sending Reset command (Op Code = 6)");
                    writeOpCode(gatt, controlPointCharacteristic, OP_CODE_RESET);
                } catch (final Exception e1) {
                    // do nothing
                }
            terminateConnection(gatt, e.getErrorNumber());
        }
    } finally {
        try {
            // upload has finished (success of fail)
            editor.putBoolean(PREFS_DFU_IN_PROGRESS, false);
            editor.commit();

            // ensure that input stream is always closed
            mHexInputStream = null;
            if (his != null)
                his.close();
            his = null;
        } catch (IOException e) {
            // do nothing
        }
    }
}

From source file:com.ccxt.whl.activity.SettingsFragment.java

/**
 * onActivityResult/*  w  ww.j  a  va2  s  .c  o  m*/
 */
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (requestCode == USERPIC_REQUEST_CODE_CAMERA) { // ?
        if (cameraFile != null && cameraFile.exists()) {
            Log.d("cameraFile" + cameraFile.getAbsolutePath());
            //?uri imageUri = Uri.fromFile(cameraFile); 
            cropImageUri(Uri.fromFile(cameraFile), 300, 300, USERPIC_REQUEST_CODE_CUT);

        }
    } else if (requestCode == USERPIC_REQUEST_CODE_LOCAL) { // ? 
        if (data != null) {
            Uri selectedImage = data.getData();
            if (selectedImage != null) {
                cropImageUri(selectedImage, 300, 300, USERPIC_REQUEST_CODE_CUT);
                //Log.d("log","selectedImage"+selectedImage);

            }
        }
    } else if (requestCode == USERPIC_REQUEST_CODE_CUT) {//?
        // ?  
        if (data != null) {
            Bitmap bitmap = data.getParcelableExtra("data");
            iv_user_photo.setImageBitmap(bitmap);

            File file = saveJPGE_After(bitmap, cameraFile); //????

            RequestParams params = new RequestParams();
            if (file.exists()) {
                try {
                    params.put("headurl", file, "image/jpeg");
                    params.put("user", DemoApplication.getInstance().getUser());
                    params.put("param", "headurl");
                    params.add("uid", uid);
                    HttpRestClient.post(Constant.UPDATE_USER_URL, params, responseHandler);
                    pd.show();
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } else {
                Toast toast = Toast.makeText(getActivity(), "?SD??",
                        Toast.LENGTH_SHORT);
            }

        } else {
            // Log.e(TAG, "CHOOSE_SMALL_PICTURE: data = " + data);

        }
        // Log.d("log","imageUribundle==>"+imageUri);
        //iv_user_photo.setImageURI(imageUri); 

        //params.put(key, file, )

        //**??data
        //Bitmap bitmap = data.getParcelableExtra("data");
        // Bitmap bitmap = data.getExtras().getParcelable("data");

        /*
        // ByteArrayOutputStream out = new ByteArrayOutputStream(); 
        // bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);  
        */

        //this.iv_image.setImageBitmap(bitmap);  
        /* }else{
           Toast toast = Toast.makeText(getActivity(), "?SD??", Toast.LENGTH_SHORT);
                   
        } */

        /*  try {  
           //   
          // tempFile.delete();  
        } catch (Exception e) {  
           e.printStackTrace();  
        }  */

        /* RequestParams params = new RequestParams(); 
         final String contentType = RequestParams.APPLICATION_OCTET_STREAM;*/
        // params.put(key, file, contentType)
        //HttpRestClient.post(url, params, responseHandler)
    }
}

From source file:com.github.socialc0de.gsw.android.MainActivity.java

/**
 * Handles the results from activities launched to select an account and to install Google Play
 * Services./*from   w ww. j a v  a 2 s . c  o  m*/
 */

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case REQUEST_ACCOUNT_PICKER:
        if (data != null && data.getExtras() != null) {
            String accountName = data.getExtras().getString(AccountManager.KEY_ACCOUNT_NAME);
            if (accountName != null) {
                onSignedIn(accountName);
            }
        } else if (!SIGN_IN_REQUIRED) {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setTitle(R.string.are_you_sure);
            alert.setMessage(R.string.not_all_features);
            alert.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    startMainActivity();
                }
            });
            alert.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
                }
            });
            alert.show();

        }
        break;
    case REQUEST_GOOGLE_PLAY_SERVICES:
        if (resultCode != Activity.RESULT_OK) {
            checkGooglePlayServicesAvailable();
        }
        break;
    }

    if (requestCode == REQUEST_CODE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PaymentConfirmation confirm = data.getParcelableExtra(PaymentActivity.EXTRA_RESULT_CONFIRMATION);
            if (confirm != null) {
                try {
                    Log.i(TAG, confirm.toJSONObject().toString(4));
                    Log.i(TAG, confirm.getPayment().toJSONObject().toString(4));
                    /**
                     *  TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
                     * or consent completion.
                     * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                     * for more details.
                     *
                     * For sample mobile backend interactions, see
                     * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
                     */
                    Toast.makeText(getApplicationContext(), "PaymentConfirmation info received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e(TAG, "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i(TAG, "The user canceled.");
        } else if (resultCode == PaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i(TAG, "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
        }
    } else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) {
        if (resultCode == Activity.RESULT_OK) {
            PayPalAuthorization auth = data
                    .getParcelableExtra(PayPalFuturePaymentActivity.EXTRA_RESULT_AUTHORIZATION);
            if (auth != null) {
                try {
                    Log.i("FuturePaymentExample", auth.toJSONObject().toString(4));

                    String authorization_code = auth.getAuthorizationCode();
                    Log.i("FuturePaymentExample", authorization_code);

                    Toast.makeText(getApplicationContext(), "Future Payment code received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e("FuturePaymentExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("FuturePaymentExample", "The user canceled.");
        } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i("FuturePaymentExample",
                    "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
        }
    } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) {
        if (resultCode == Activity.RESULT_OK) {
            PayPalAuthorization auth = data
                    .getParcelableExtra(PayPalProfileSharingActivity.EXTRA_RESULT_AUTHORIZATION);
            if (auth != null) {
                try {
                    Log.i("ProfileSharingExample", auth.toJSONObject().toString(4));

                    String authorization_code = auth.getAuthorizationCode();
                    Log.i("ProfileSharingExample", authorization_code);

                    Toast.makeText(getApplicationContext(), "Profile Sharing code received from PayPal",
                            Toast.LENGTH_LONG).show();

                } catch (JSONException e) {
                    Log.e("ProfileSharingExample", "an extremely unlikely failure occurred: ", e);
                }
            }
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Log.i("ProfileSharingExample", "The user canceled.");
        } else if (resultCode == PayPalFuturePaymentActivity.RESULT_EXTRAS_INVALID) {
            Log.i("ProfileSharingExample",
                    "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
        }
    }
}

From source file:com.gdgdevfest.android.apps.devfestbcn.ui.tablet.SessionsSandboxMultiPaneActivity.java

private void routeIntent(Intent intent, boolean updateSurfaceOnly) {
    Uri uri = intent.getData();/*www. j  av  a  2  s. com*/
    if (uri == null) {
        return;
    }

    if (intent.hasExtra(Intent.EXTRA_TITLE)) {
        setTitle(intent.getStringExtra(Intent.EXTRA_TITLE));
    }

    String mimeType = getContentResolver().getType(uri);

    if (ScheduleContract.Tracks.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load track details
        showFullUI(true);
        if (!updateSurfaceOnly) {
            // TODO: don't assume the URI will contain the track ID
            int defaultViewType = intent.getIntExtra(EXTRA_DEFAULT_VIEW_TYPE,
                    TracksDropdownFragment.VIEW_TYPE_SESSIONS);
            String selectedTrackId = ScheduleContract.Tracks.getTrackId(uri);
            loadTrackList(defaultViewType, selectedTrackId);
            getSupportActionBar().setSelectedNavigationItem(defaultViewType);
            onTrackSelected(selectedTrackId);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_TYPE.equals(mimeType)) {
        // Load a session list, hiding the tracks dropdown and the tabs
        mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            loadSessionList(uri, null);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sessions.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load session details
        if (intent.hasExtra(EXTRA_MASTER_URI)) {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS;
            showFullUI(false);
            if (!updateSurfaceOnly) {
                loadSessionList((Uri) intent.getParcelableExtra(EXTRA_MASTER_URI),
                        ScheduleContract.Sessions.getSessionId(uri));
                loadSessionDetail(uri);
            }
        } else {
            mViewType = TracksDropdownFragment.VIEW_TYPE_SESSIONS; // prepare for onTrackInfo...
            showFullUI(true);
            if (!updateSurfaceOnly) {
                loadSessionDetail(uri);
                loadTrackInfoFromSessionUri(uri);
            }
        }

    } else if (ScheduleContract.Sandbox.CONTENT_TYPE.equals(mimeType)) {
        // Load a sandbox company list
        mViewType = TracksDropdownFragment.VIEW_TYPE_SANDBOX;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            loadSandboxList(uri, null);
            mSlidingPaneLayout.openPane();
        }

    } else if (ScheduleContract.Sandbox.CONTENT_ITEM_TYPE.equals(mimeType)) {
        // Load company details
        mViewType = TracksDropdownFragment.VIEW_TYPE_SANDBOX;
        showFullUI(false);
        if (!updateSurfaceOnly) {
            Uri masterUri = intent.getParcelableExtra(EXTRA_MASTER_URI);
            if (masterUri == null) {
                masterUri = ScheduleContract.Sandbox.CONTENT_URI;
            }
            loadSandboxList(masterUri, ScheduleContract.Sandbox.getCompanyId(uri));
            loadSandboxDetail(uri);
        }
    }

    updateDetailBackground();
}