List of usage examples for android.content Intent getParcelableExtra
public <T extends Parcelable> T getParcelableExtra(String name)
From source file:com.android.purenexussettings.TinkerActivity.java
@Override protected void onActivityResult(int paramRequest, int paramResult, Intent paramData) { super.onActivityResult(paramRequest, paramResult, paramData); if (paramResult != -1 || paramData == null) { return;/*from www. ja v a 2 s .c o m*/ } switch (paramRequest) { case REQUEST_CREATE_SHORTCUT: Intent localIntent = paramData.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); localIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, paramData.getStringExtra(Intent.EXTRA_SHORTCUT_NAME)); String keystring = localIntent.toUri(0).replaceAll("com.android.contacts.action.QUICK_CONTACT", Intent.ACTION_VIEW); Settings.Global.putString(getContentResolver(), TinkerActivity.mPrefKey, keystring); onBackPressed(); return; default: } }
From source file:com.jefftharris.passwdsafe.sync.gdriveplay.GDrivePlayMainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); PasswdSafeUtil.dbginfo(TAG, "onActivityResult req %d res %d data %s", requestCode, resultCode, data); switch (requestCode) { case GDRIVE_RESOLUTION_RC: { if (resultCode == RESULT_OK) { itsClient.connect();//from w w w . java 2 s. c o m } else { finish(); } break; } case ADD_FILE_RC: { if (resultCode != RESULT_OK) { break; } DriveId driveId = data.getParcelableExtra(OpenFileActivityBuilder.EXTRA_RESPONSE_DRIVE_ID); PasswdSafeUtil.dbginfo(TAG, "open file id: %s", driveId); itsAddFiles.add(driveId); } } }
From source file:com.polyvi.xface.extension.camera.XCameraExt.java
/** * ?URI?Bitmap//from ww w.jav a 2 s .co m * * @param intent ???URIintent * @return Bitmap ?intentURI? */ private Bitmap getCroppedBitmap(Intent intent) { Bitmap bitmap = null; InputStream is = null; Uri uri = null; //??URI? if (intent == null) { uri = mCroppedImageUri; } else { uri = intent.getParcelableExtra(ImageCroppingActivity.CROPPED_IMAGE_URI); } try { is = getInputStream(uri); bitmap = BitmapFactory.decodeStream(is); } catch (IOException e) { e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException ignored) { } } } return bitmap; }
From source file:cn.edu.zafu.corepage.base.BaseActivity.java
/** * ?intent/* ww w .j a va 2 s . c o m*/ * * @param mNewIntent Intent */ private void init(Intent mNewIntent) { try { CoreSwitchBean page = mNewIntent.getParcelableExtra("SwitchBean"); String startActivityForResult = mNewIntent.getStringExtra("startActivityForResult"); this.mFirstCoreSwitchBean = page; if (page != null) { BaseFragment fragment = null; boolean addToBackStack = page.isAddToBackStack(); String pageName = page.getPageName(); Bundle bundle = page.getBundle(); fragment = (BaseFragment) CorePageManager.getInstance().openPageWithNewFragmentManager( getSupportFragmentManager(), pageName, bundle, null, addToBackStack); if (fragment != null) { if ("true".equalsIgnoreCase(startActivityForResult)) { fragment.setRequestCode(page.getRequestCode()); fragment.setFragmentFinishListener(new BaseFragment.OnFragmentFinishListener() { @Override public void onFragmentResult(int requestCode, int resultCode, Intent intent) { BaseActivity.this.setResult(resultCode, intent); } }); } } else { this.finish(); } } } catch (Exception e) { e.printStackTrace(); Log.d(TAG, e.getMessage()); this.finish(); } }
From source file:com.owncloud.android.files.services.FileDownloader.java
/** * Entry point to add one or several files to the queue of downloads. * * New downloads are added calling to startService(), resulting in a call to this method. * This ensures the service will keep on working although the caller activity goes away. *//* w w w.j av a2s .co m*/ @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE)) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); final OCFile file = intent.getParcelableExtra(EXTRA_FILE); AbstractList<String> requestedDownloads = new Vector<String>(); try { DownloadFileOperation newDownload = new DownloadFileOperation(account, file); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); Pair<String, String> putResult = mPendingDownloads.putIfAbsent(account, file.getRemotePath(), newDownload); String downloadKey = putResult.first; requestedDownloads.add(downloadKey); sendBroadcastNewDownload(newDownload, putResult.second); } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } if (requestedDownloads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedDownloads; mServiceHandler.sendMessage(msg); } //} } return START_NOT_STICKY; }
From source file:com.cerema.cloud2.files.services.FileDownloader.java
/** * Entry point to add one or several files to the queue of downloads. * * New downloads are added calling to startService(), resulting in a call to this method. * This ensures the service will keep on working although the caller activity goes away. *///from w ww. j a v a 2 s . c o m @Override public int onStartCommand(Intent intent, int flags, int startId) { Log_OC.d(TAG, "Starting command with id " + startId); if (!intent.hasExtra(EXTRA_ACCOUNT) || !intent.hasExtra(EXTRA_FILE)) { Log_OC.e(TAG, "Not enough information provided in intent"); return START_NOT_STICKY; } else { final Account account = intent.getParcelableExtra(EXTRA_ACCOUNT); final OCFile file = intent.getParcelableExtra(EXTRA_FILE); AbstractList<String> requestedDownloads = new Vector<String>(); try { DownloadFileOperation newDownload = new DownloadFileOperation(account, file); newDownload.addDatatransferProgressListener(this); newDownload.addDatatransferProgressListener((FileDownloaderBinder) mBinder); Pair<String, String> putResult = mPendingDownloads.putIfAbsent(account, file.getRemotePath(), newDownload); if (putResult != null) { String downloadKey = putResult.first; requestedDownloads.add(downloadKey); sendBroadcastNewDownload(newDownload, putResult.second); } // else, file already in the queue of downloads; don't repeat the request } catch (IllegalArgumentException e) { Log_OC.e(TAG, "Not enough information provided in intent: " + e.getMessage()); return START_NOT_STICKY; } if (requestedDownloads.size() > 0) { Message msg = mServiceHandler.obtainMessage(); msg.arg1 = startId; msg.obj = requestedDownloads; mServiceHandler.sendMessage(msg); } //} } return START_NOT_STICKY; }
From source file:org.exoplatform.shareextension.ShareActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // When we come back from the space selector activity // TODO make it another fragment if (requestCode == SELECT_SHARE_DESTINATION) { if (resultCode == RESULT_OK) { SocialSpaceInfo space = (SocialSpaceInfo) data .getParcelableExtra(SpaceSelectorActivity.SELECTED_SPACE); ComposeFragment composer = ComposeFragment.getFragment(); if (space != null) { composer.setSpaceSelectorLabel(space.displayName); } else { composer.setSpaceSelectorLabel(getResources().getString(R.string.Public)); }// w ww. jav a 2 s .c o m postInfo.destinationSpace = space; } } }
From source file:com.google.android.apps.muzei.api.MuzeiArtSource.java
@Override protected void onHandleIntent(Intent intent) { if (intent == null) { return;//from ww w.ja v a 2 s . c o m } String action = intent.getAction(); // TODO: permissions? if (ACTION_SUBSCRIBE.equals(action)) { processSubscribe((ComponentName) intent.getParcelableExtra(EXTRA_SUBSCRIBER_COMPONENT), intent.getStringExtra(EXTRA_TOKEN)); } else if (ACTION_HANDLE_COMMAND.equals(action)) { int commandId = intent.getIntExtra(EXTRA_COMMAND_ID, 0); processHandleCommand(commandId, intent.getExtras()); } else if (ACTION_NETWORK_AVAILABLE.equals(action)) { processNetworkAvailable(); } }
From source file:com.notalenthack.blaster.CommandActivity.java
/** * Called when the activity is first created. *//*from w w w.jav a 2s.com*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mThisActivity = this; final Intent launchingIntent = getIntent(); // Retrieve the Query Type and Position from the intent or bundle if (savedInstanceState != null) { mDevice = savedInstanceState.getParcelable(Constants.KEY_DEVICE_STATE); } else if (launchingIntent != null) { mDevice = launchingIntent.getParcelableExtra(Constants.KEY_DEVICE_STATE); } setContentView(R.layout.commands); // get the fields mModelName = (TextView) findViewById(R.id.modelName); mCores = (TextView) findViewById(R.id.cores); mCacheSize = (TextView) findViewById(R.id.cacheSize); mConnectStatus = (TextView) findViewById(R.id.status); mDeviceStatus = (ImageView) findViewById(R.id.deviceStatusIcon); mBatteryStatus = (ImageView) findViewById(R.id.batteryStatus); mCmdListView = (ListView) findViewById(R.id.listView); ; mBtnExecAll = (Button) findViewById(R.id.btnExecAll); if (mDevice != null) { getActionBar().setHomeButtonEnabled(true); getActionBar().setIcon(R.drawable.ic_action_navigation_previous_item); mSerialService = new BluetoothSerialService(this, mHandlerBT); mSerialService.connect(mDevice.getBluetoothDevice()); // Execute all the commands mBtnExecAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // do a quick status update on the commands List<Command> commands = mListAdapter.getCommands(); // this list should be in the same order as in the ListBox for (Command cmd : commands) { if (cmd.getCommandStart().equalsIgnoreCase(Command.LAUNCHER_START)) { launchCommand(cmd); } else if (!cmd.getCommandStart().equalsIgnoreCase(Command.OBEX_FTP_START)) { executeCommand(cmd); } } } }); setupCommandList(); } else { Log.e(TAG, "Bluetooth device is not initialized"); finish(); } }
From source file:com.nicolatesser.geofencedemo.LocationActivity.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); // getIntent() should always return the most recent setIntent(intent);/* w w w.ja v a 2 s .com*/ boolean receiverStarted = intent.getBooleanExtra("RECEIVER_STARTED", false); if (!receiverStarted) { return; } Bundle bundle = intent.getParcelableExtra("geo_fences"); ArrayList<String> requestIds = bundle.getStringArrayList("request_ids"); if (requestIds == null) { Log.v(LocationActivity.TAG, "request_ids == null"); return; } int transition = intent.getIntExtra("transition", -2); for (String requestId : requestIds) { Log.v(LocationActivity.TAG, "Triggering Geo Fence requestId " + requestId); if (transition == Geofence.GEOFENCE_TRANSITION_ENTER) { Circle circle = mGeoFences.get(requestId); if (circle == null) { continue; } Log.v(LocationActivity.TAG, "triggering_geo_fences enter == " + requestId); // Add a superimposed red circle when a geofence is entered and // put the corresponding object in triggering_fences. CircleOptions circleOptions = new CircleOptions(); circleOptions.center(circle.getCenter()).radius(circle.getRadius()) .fillColor(Color.argb(100, 100, 0, 0)); Circle newCircle = mMap.addCircle(circleOptions); mTriggeringFences.put(requestId, newCircle); // LocationLoggerService.getInstance().writeActivity( // DemoConstant.NAME, "Entered in Geofence"); } else if (transition == Geofence.GEOFENCE_TRANSITION_EXIT) { Log.v(LocationActivity.TAG, "triggering_geo_fences exit == " + requestId); Circle circle = mTriggeringFences.get(requestId); if (circle == null) { continue; } // Remove the superimposed red circle from the map and the // corresponding Circle object from triggering_fences hash_map. circle.remove(); mTriggeringFences.remove(requestId); // LocationLoggerService.getInstance().writeActivity( // DemoConstant.NAME, "Exited from Geofence"); } } return; }