List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.meetingninja.csse.meetings.MeetingsFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == 2) { if (resultCode == Activity.RESULT_OK) { if (data != null) { int listPosition = data.getIntExtra("listPosition", -1); Meeting created = data.getParcelableExtra(Keys.Meeting.PARCEL); if (data.getStringExtra("method").equals("update")) { Log.d(TAG, "Updating Meeting"); if (listPosition != -1) updateMeeting(listPosition, created); else updateMeeting(created); } else if (data.getStringExtra("method").equals("insert")) { Log.d(TAG, "Inserting Meeting"); // created = mySQLiteAdapter.insertMeeting(created); fetchMeetings();//w w w. j a v a 2 s . c o m } } } else { if (resultCode == Activity.RESULT_CANCELED) { // nothing to do here } } } }
From source file:com.mutu.gpstracker.streaming.CustomUpload.java
@Override public void onReceive(Context context, Intent intent) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); String prefUrl = preferences.getString(ApplicationPreferenceActivity.CUSTOMUPLOAD_URL, "http://www.example.com"); Integer prefBacklog = Integer.valueOf(preferences .getString(ApplicationPreferenceActivity.CUSTOMUPLOAD_BACKLOG, CUSTOMUPLOAD_BACKLOG_DEFAULT)); Location loc = intent.getParcelableExtra(Constants.EXTRA_LOCATION); Uri trackUri = intent.getParcelableExtra(Constants.EXTRA_TRACK); String buildUrl = prefUrl;//from w w w . jav a2 s . c o m buildUrl = buildUrl.replace("@LAT@", Double.toString(loc.getLatitude())); buildUrl = buildUrl.replace("@LON@", Double.toString(loc.getLongitude())); buildUrl = buildUrl.replace("@ID@", trackUri.getLastPathSegment()); buildUrl = buildUrl.replace("@TIME@", Long.toString(loc.getTime())); buildUrl = buildUrl.replace("@SPEED@", Float.toString(loc.getSpeed())); buildUrl = buildUrl.replace("@ACC@", Float.toString(loc.getAccuracy())); buildUrl = buildUrl.replace("@ALT@", Double.toString(loc.getAltitude())); buildUrl = buildUrl.replace("@BEAR@", Float.toString(loc.getBearing())); HttpClient client = new DefaultHttpClient(); URI uploadUri; try { uploadUri = new URI(buildUrl); HttpGet currentRequest = new HttpGet(uploadUri); sRequestBacklog.add(currentRequest); if (sRequestBacklog.size() > prefBacklog) { sRequestBacklog.poll(); } while (!sRequestBacklog.isEmpty()) { HttpGet request = sRequestBacklog.peek(); HttpResponse response = client.execute(request); sRequestBacklog.poll(); StatusLine status = response.getStatusLine(); if (status.getStatusCode() != 200) { throw new IOException("Invalid response from server: " + status.toString()); } clearNotification(context); } } catch (URISyntaxException e) { notifyError(context, e); } catch (ClientProtocolException e) { notifyError(context, e); } catch (IOException e) { notifyError(context, e); } }
From source file:com.ez.gallery.ucrop.UCropActivity.java
/** * This method extracts all data from the incoming intent and setups views properly. */// w w w . j ava 2 s .c o m private void setImageData() { final Intent intent = getIntent(); Uri inputUri = intent.getParcelableExtra(UCrop.EXTRA_INPUT_URI); mOutputUri = intent.getParcelableExtra(UCrop.EXTRA_OUTPUT_URI); processOptions(intent); if (inputUri != null && mOutputUri != null) { try { mGestureCropImageView.setImageUri(inputUri); } catch (Exception e) { Toast.makeText(getApplication(), "xxxx", Toast.LENGTH_SHORT).show(); setResultException(e); finish(); } } else { Toast.makeText(getApplication(), "fffff", Toast.LENGTH_SHORT).show(); setResultException(new NullPointerException(getString(R.string.ucrop_error_input_data_is_absent))); finish(); } if (intent.getBooleanExtra(UCrop.EXTRA_ASPECT_RATIO_SET, false)) { mWrapperStateAspectRatio.setVisibility(View.GONE); int aspectRatioX = intent.getIntExtra(UCrop.EXTRA_ASPECT_RATIO_X, 0); int aspectRatioY = intent.getIntExtra(UCrop.EXTRA_ASPECT_RATIO_Y, 0); if (aspectRatioX > 0 && aspectRatioY > 0) { mGestureCropImageView.setTargetAspectRatio(aspectRatioX / (float) aspectRatioY); } else { mGestureCropImageView.setTargetAspectRatio(CropImageView.SOURCE_IMAGE_ASPECT_RATIO); } } if (intent.getBooleanExtra(UCrop.EXTRA_MAX_SIZE_SET, false)) { int maxSizeX = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_X, 0); int maxSizeY = intent.getIntExtra(UCrop.EXTRA_MAX_SIZE_Y, 0); if (maxSizeX > 0 && maxSizeY > 0) { mGestureCropImageView.setMaxResultImageSizeX(maxSizeX); mGestureCropImageView.setMaxResultImageSizeY(maxSizeY); } else { Log.w(TAG, "EXTRA_MAX_SIZE_X and EXTRA_MAX_SIZE_Y must be greater than 0"); } } }
From source file:com.example.RITW.Ble.BleProfileService.java
@Override public int onStartCommand(final Intent intent, final int flags, final int startId) { if (intent == null || !intent.hasExtra(EXTRA_DEVICE_ADDRESS)) throw new UnsupportedOperationException("No device address at EXTRA_DEVICE_ADDRESS key"); final Uri logUri = intent.getParcelableExtra(EXTRA_LOG_URI); // mLogSession = Logger.openSession(getApplicationContext(), logUri); mDeviceAddress = intent.getStringExtra(EXTRA_DEVICE_ADDRESS); // Logger.i(mLogSession, "Service started"); // notify user about changing the state to CONNECTING final Intent broadcast = new Intent(BROADCAST_CONNECTION_STATE); broadcast.putExtra(EXTRA_CONNECTION_STATE, STATE_CONNECTING); LocalBroadcastManager.getInstance(BleProfileService.this).sendBroadcast(broadcast); final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE); final BluetoothAdapter adapter = bluetoothManager.getAdapter(); final BluetoothDevice device = adapter.getRemoteDevice(mDeviceAddress); mDeviceName = device.getName();/*from w w w .j a v a 2s.co m*/ onServiceStarted(); // Logger.v(mLogSession, "Connecting..."); mBleManager.connect(BleProfileService.this, device); return START_REDELIVER_INTENT; }
From source file:mobisocial.socialkit.musubi.Musubi.java
public void setDataFromIntent(Intent intent) { if (intent.hasExtra(EXTRA_FEED_URI)) { mFeed = new DbFeed(this, (Uri) intent.getParcelableExtra(EXTRA_FEED_URI)); }//from w w w .ja v a 2 s. co m if (mObj == null) { if (intent.hasExtra(EXTRA_OBJ_URI)) { mObj = objForUri((Uri) intent.getParcelableExtra(EXTRA_OBJ_URI)); } else { mObj = objForUri(intent.getData()); } } }
From source file:com.goliathonline.android.kegbot.ui.DrinkDetailFragment.java
/** * Derive {@link com.goliathonline.android.kegbot.provider.KegbotContract.Kegs#CONTENT_ITEM_TYPE} * {@link Uri} based on incoming {@link Intent}, using * {@link #EXTRA_TRACK} when set.//from w ww .j a v a 2 s . c o m * @param intent * @return Uri */ private Uri resolveKegUri(Intent intent) { final Uri kegUri = intent.getParcelableExtra(EXTRA_TRACK); if (kegUri != null) { return kegUri; } else { return KegbotContract.Drinks.buildKegUri(mDrinkId); } }
From source file:com.owncloud.android.ui.activity.FolderSyncActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == SyncedFolderPreferencesDialogFragment.REQUEST_CODE__SELECT_REMOTE_FOLDER && resultCode == RESULT_OK && mSyncedFolderPreferencesDialogFragment != null) { OCFile chosenFolder = data.getParcelableExtra(FolderPickerActivity.EXTRA_FOLDER); mSyncedFolderPreferencesDialogFragment.setRemoteFolderSummary(chosenFolder.getRemotePath()); } else {//from w ww . j a va 2s . com super.onActivityResult(requestCode, resultCode, data); } }
From source file:com.danxx.brisktvlauncher.ui.FullScreenVideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent(); String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown ccheme\n"); finish();/*from www. j ava 2 s . co m*/ return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); // mMediaController = new AndroidMediaController(this, false); // mMediaController.setSupportActionBar(actionBar); customMediaController = new CustomMediaController(this, false); customMediaController.setSupportActionBar(actionBar); actionBar.setDisplayHomeAsUpEnabled(true); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(customMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }
From source file:com.amagi82.kerbalspaceapp.MissionPlanner.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && data != null) { MissionData result = data.getParcelableExtra("returnItem"); if (data.getBooleanExtra("isNewItem", true)) { missionData.add(result);/*from ww w . j av a2 s . c o m*/ } else { missionData.set(requestCode, result); } mAdapter.notifyDataSetChanged(); refreshDeltaV(); } if (resultCode == RESULT_CANCELED) { } }
From source file:firefist.wei.sliding.fragment.LeftFragment.java
public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); left_top_layout.setOnClickListener(new View.OnClickListener() { @Override//from w w w .j ava 2s . c o m public void onClick(View v) { Intent intent = new Intent(getActivity(), Primary_MyInfo.class); startActivity(intent); } }); Renren renren; Intent intent = MainActivity.instance.getIntent(); renren = intent.getParcelableExtra(Renren.RENREN_LABEL); if (renren != null) { renren.init(MainActivity.instance); } if (renren != null) { AsyncRenren asyncRenren = new AsyncRenren(renren); String uids[] = parseCommaIds("338916467"); if (uids == null) { return; } UsersGetInfoRequestParam param = new UsersGetInfoRequestParam(uids); AbstractRequestListener<UsersGetInfoResponseBean> listener = new AbstractRequestListener<UsersGetInfoResponseBean>() { @Override public void onComplete(final UsersGetInfoResponseBean bean) { MainActivity.instance.runOnUiThread(new Runnable() { String json = null; String renren_name = null; String renren_headurl = null; @Override public void run() { String json = bean.toString(); if (json != null) { parseJson(); if (renren_name != null) { left_name.setText(renren_name); } } Log.v("RenRen", bean.toString()); } private void parseJson() { try { JSONArray array = new JSONArray(json); for (int i = 0; i < array.length(); i++) { renren_name = array.getJSONObject(i).getString("name"); renren_headurl = array.getJSONObject(i).getString("headurl"); } } catch (JSONException e) { e.printStackTrace(); } } }); } @Override public void onRenrenError(final RenrenError renrenError) { new Runnable() { @Override public void run() { Log.v("RenRen", renrenError.getMessage()); } }; } @Override public void onFault(final Throwable fault) { new Runnable() { @Override public void run() { Log.v("RenRen", fault.getMessage()); } }; } }; asyncRenren.getUsersInfo(param, listener); } }