List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:com.jetheis.android.grades.billing.googleplay.GooglePlayBillingWrapper.java
@Override public void requestPurchase(String itemId) { Log.d(Constants.TAG, "Requesting purchase of " + itemId); Bundle response; try {//from ww w . java 2s. c om response = mBoundService.makeGooglePlayPurchaseRequest(itemId); } catch (RemoteException e) { Log.e(Constants.TAG, "RemoteException: " + e.getLocalizedMessage()); return; } if (response.getInt( GooglePlayBillingConstants.GOOGLE_PLAY_BUNDLE_KEY_RESPONSE_CODE) != GooglePlayResponseCode.RESULT_OK .ordinal()) { return; } PendingIntent pendingIntent = response .getParcelable(GooglePlayBillingConstants.GOOGLE_PLAY_BUNDLE_KEY_PURCHASE_INTENT); try { mContext.startIntentSender(pendingIntent.getIntentSender(), new Intent(), 0, 0, 0); } catch (SendIntentException e) { Log.e(Constants.TAG, "SendIntentException: " + e.getLocalizedMessage()); } }
From source file:com.digitalarx.android.ui.activity.FileActivity.java
/** * Loads the ownCloud {@link Account} and main {@link OCFile} to be handled by the instance of * the {@link FileActivity}.//from w w w .j av a 2 s. com * * Grants that a valid ownCloud {@link Account} is associated to the instance, or that the user * is requested to create a new one. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mHandler = new Handler(); mFileOperationsHelper = new FileOperationsHelper(this); Account account; if (savedInstanceState != null) { account = savedInstanceState.getParcelable(FileActivity.EXTRA_ACCOUNT); mFile = savedInstanceState.getParcelable(FileActivity.EXTRA_FILE); mFromNotification = savedInstanceState.getBoolean(FileActivity.EXTRA_FROM_NOTIFICATION); mFileOperationsHelper .setOpIdWaitingFor(savedInstanceState.getLong(KEY_WAITING_FOR_OP_ID, Long.MAX_VALUE)); } else { account = getIntent().getParcelableExtra(FileActivity.EXTRA_ACCOUNT); mFile = getIntent().getParcelableExtra(FileActivity.EXTRA_FILE); mFromNotification = getIntent().getBooleanExtra(FileActivity.EXTRA_FROM_NOTIFICATION, false); } setAccount(account, savedInstanceState != null); mOperationsServiceConnection = new OperationsServiceConnection(); bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection, Context.BIND_AUTO_CREATE); mDownloadServiceConnection = newTransferenceServiceConnection(); if (mDownloadServiceConnection != null) { bindService(new Intent(this, FileDownloader.class), mDownloadServiceConnection, Context.BIND_AUTO_CREATE); } mUploadServiceConnection = newTransferenceServiceConnection(); if (mUploadServiceConnection != null) { bindService(new Intent(this, FileUploader.class), mUploadServiceConnection, Context.BIND_AUTO_CREATE); } }
From source file:com.adkdevelopment.earthquakesurvival.ui.MapviewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.map_fragment, container, false); mUnbinder = ButterKnife.bind(this, rootView); mMarkers = new ArrayList<>(); if (Utilities.checkPlayServices(getActivity())) { mMapView.onCreate(savedInstanceState); mMapView.getMapAsync(this); }/*w ww . j a va 2s.c o m*/ if (savedInstanceState != null) { mCameraPosition = savedInstanceState.getParcelable(CAMERA_POSITION); } else { mCameraPosition = CameraPosition.builder().target(LocationUtils.getLocation(getContext())) .zoom(LocationUtils.CAMERA_DEFAULT_ZOOM).build(); } return rootView; }
From source file:eu.faircode.netguard.IAB.java
public PendingIntent getBuyIntent(String sku, boolean subscription) throws RemoteException { if (service == null) return null; Bundle bundle = service.getBuyIntent(IAB_VERSION, context.getPackageName(), sku, subscription ? "subs" : "inapp", "netguard"); Log.i(TAG, "getBuyIntent sku=" + sku + " subscription=" + subscription); Util.logBundle(bundle);/* w w w. jav a2 s.co m*/ int response = (bundle == null ? -1 : bundle.getInt("RESPONSE_CODE", -1)); Log.i(TAG, "Response=" + getResult(response)); if (response != 0) throw new IllegalArgumentException(getResult(response)); if (!bundle.containsKey("BUY_INTENT")) throw new IllegalArgumentException("BUY_INTENT missing"); return bundle.getParcelable("BUY_INTENT"); }
From source file:com.cyanogenmod.messaging.quickmessage.QuickMessagePopup.java
private void parseIntent(Bundle extras, boolean newMessage) { if (extras == null) { return;/*from w w w .j av a 2 s . c o m*/ } // Parse the intent and ensure we have a notification object to work with NotificationInfo nm = extras.getParcelable(SMS_NOTIFICATION_OBJECT_EXTRA); if (nm != null) { QuickMessage qm = new QuickMessage(nm); markCurrentMessageRead(qm); mMessageList.add(qm); mPagerAdapter.notifyDataSetChanged(); // If triggered from Quick Reply the keyboard should be visible immediately if (extras.getBoolean(QR_SHOW_KEYBOARD_EXTRA, false)) { getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); } if (newMessage && mCurrentPage != -1) { // There is already a message showing // Stay on the current message mMessagePager.setCurrentItem(mCurrentPage); } else { // Set the current message to the last message received mCurrentPage = mMessageList.size() - 1; mMessagePager.setCurrentItem(mCurrentPage); } if (DEBUG) Log.d(LOG_TAG, "parseIntent(): New message from " + qm.getFromName().toString() + " added. Number of messages = " + mMessageList.size() + ". Displaying page #" + (mCurrentPage + 1)); } }
From source file:com.polyvi.xface.extension.camera.XCameraExt.java
private void cameraSucess(Intent intent) { try {// w ww . java2 s .c om Bitmap bitmap = null; try { //???imagebitmap if (mAllowEdit) { //??????Android??? //???URI Bundle extras = intent.getExtras(); if (extras != null) { bitmap = extras.getParcelable("data"); } //?????URI if ((bitmap == null) || (extras == null)) { bitmap = getCroppedBitmap(intent); } } else { // ???? bitmap = android.provider.MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), mImageUri); } } catch (FileNotFoundException e) { Uri uri = intent.getData(); android.content.ContentResolver resolver = getContext().getContentResolver(); bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); } catch (IOException e) { mCallbackCtx.error("Can't open image"); } catch (OutOfMemoryError e) { XNotification notification = new XNotification(mExtensionContext.getSystemContext()); notification.alert("Size of Image is too large!", "Save Image Error", "OK", null, DURATION); mCallbackCtx.error("Size of image is too large"); return; } // ??? Bitmap scaleBitmap = scaleBitmap(bitmap); Uri uri = null; if (mDestType == DATA_URL) { processPicture(scaleBitmap); checkForDuplicateImage(DATA_URL); } else if (mDestType == FILE_URI || mDestType == NATIVE_URI) { if (!this.mSaveToPhotoAlbum) { String suffixName = null; if (mEncodingType == JPEG) { suffixName = ".jpg"; } else if (mEncodingType == PNG) { suffixName = ".png"; } else { throw new IllegalArgumentException("Invalid Encoding Type: " + mEncodingType); } String photoName = System.currentTimeMillis() + suffixName; uri = Uri.fromFile(new File(mWebContext.getWorkSpace(), photoName)); } else { uri = getUriFromMediaStore(); } if (uri == null) { mCallbackCtx.error("Error capturing image - no media storage found."); } // ? OutputStream os = getContext().getContentResolver().openOutputStream(uri); scaleBitmap.compress(Bitmap.CompressFormat.JPEG, mQuality, os); os.close(); // ??success callback XPathResolver pathResolver = new XPathResolver(uri.toString(), "", getContext()); mCallbackCtx.success(XConstant.FILE_SCHEME + pathResolver.resolve()); } scaleBitmap.recycle(); scaleBitmap = null; cleanup(FILE_URI, mImageUri, uri, bitmap); } catch (IOException e) { mCallbackCtx.error("Error capturing image."); } }
From source file:com.facebook.login.DeviceAuthDialog.java
@Nullable @Override/* w w w. java2 s . c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); FacebookActivity facebookActivity = (FacebookActivity) getActivity(); LoginFragment fragment = (LoginFragment) facebookActivity.getCurrentFragment(); deviceAuthMethodHandler = (DeviceAuthMethodHandler) fragment.getLoginClient().getCurrentHandler(); if (savedInstanceState != null) { RequestState requestState = savedInstanceState.getParcelable(REQUEST_STATE_KEY); if (requestState != null) { setCurrentRequestState(requestState); } } return view; }
From source file:com.cloudbees.gasp.service.RESTService.java
@Override protected void onHandleIntent(Intent intent) { // When an intent is received by this Service, this method // is called on a new thread. Uri action = intent.getData();// ww w . ja va 2s. c o m Bundle extras = intent.getExtras(); if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) { // Extras contain our ResultReceiver and data is our REST action. // So, without these components we can't do anything useful. Log.e(TAG, "You did not pass extras or data with the Intent."); return; } // We default to GET if no verb was specified. int verb = extras.getInt(EXTRA_HTTP_VERB, GET); Bundle params = extras.getParcelable(EXTRA_PARAMS); ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER); try { // Here we define our base request object which we will // send to our REST service via HttpClient. HttpRequestBase request = null; // Let's build our request based on the HTTP verb we were // given. switch (verb) { case GET: { request = new HttpGet(); attachUriWithQuery(request, action, params); } break; case DELETE: { request = new HttpDelete(); attachUriWithQuery(request, action, params); } break; case POST: { request = new HttpPost(); request.setURI(new URI(action.toString())); // Attach form entity if necessary. Note: some REST APIs // require you to POST JSON. This is easy to do, simply use // postRequest.setHeader('Content-Type', 'application/json') // and StringEntity instead. Same thing for the PUT case // below. HttpPost postRequest = (HttpPost) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); postRequest.setEntity(formEntity); } } break; case PUT: { request = new HttpPut(); request.setURI(new URI(action.toString())); // Attach form entity if necessary. HttpPut putRequest = (HttpPut) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); putRequest.setEntity(formEntity); } } break; } if (request != null) { HttpClient client = new DefaultHttpClient(); // Let's send some useful debug information so we can monitor things // in LogCat. Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString()); // Finally, we send our request using HTTP. This is the synchronous // long operation that we need to run on this thread. HttpResponse response = client.execute(request); HttpEntity responseEntity = response.getEntity(); StatusLine responseStatus = response.getStatusLine(); int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0; // Our ResultReceiver allows us to communicate back the results to the caller. This // class has a method named send() that can send back a code and a Bundle // of data. ResultReceiver and IntentService abstract away all the IPC code // we would need to write to normally make this work. if (responseEntity != null) { Bundle resultData = new Bundle(); resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity)); receiver.send(statusCode, resultData); } else { receiver.send(statusCode, null); } } } catch (URISyntaxException e) { Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e); receiver.send(0, null); } catch (UnsupportedEncodingException e) { Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e); receiver.send(0, null); } catch (ClientProtocolException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } catch (IOException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } }
From source file:org.anhonesteffort.flock.SubscriptionGoogleFragment.java
private void handleRequestPurchaseIntent(final String productType, final String productSku) { if (asyncTask != null) return;/*from w ww . j a va 2 s .c o m*/ asyncTask = new AsyncTask<Void, Void, Bundle>() { @Override protected void onPreExecute() { Log.d(TAG, "handleRequestPurchaseIntent"); subscriptionActivity.setProgressBarIndeterminateVisibility(true); subscriptionActivity.setProgressBarVisibility(true); } @Override protected Bundle doInBackground(Void... params) { Bundle result = new Bundle(); if (subscriptionActivity.billingService == null) { Log.e(TAG, "billing service is null"); result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR); return result; } String developerPayload = Base64 .encodeBytes(subscriptionActivity.davAccount.getUserId().toUpperCase().getBytes()); try { Bundle intentBundle = subscriptionActivity.billingService.getBuyIntent(3, SubscriptionGoogleFragment.class.getPackage().getName(), productSku, productType, developerPayload); if (intentBundle.getParcelable("BUY_INTENT") != null) { result.putParcelable("BUY_INTENT", intentBundle.getParcelable("BUY_INTENT")); result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SUCCESS); return result; } Log.e(TAG, "buy intent is null"); } catch (RemoteException e) { Log.e(TAG, "caught remote exception while getting buy intent", e); } result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_GOOGLE_PLAY_ERROR); return result; } @Override protected void onPostExecute(Bundle result) { asyncTask = null; subscriptionActivity.setProgressBarIndeterminateVisibility(false); subscriptionActivity.setProgressBarVisibility(false); if (result.getInt(ErrorToaster.KEY_STATUS_CODE) == ErrorToaster.CODE_SUCCESS) handleStartPurchaseIntent((PendingIntent) result.getParcelable("BUY_INTENT")); else ErrorToaster.handleDisplayToastBundledError(subscriptionActivity, result); } }.execute(); }
From source file:br.com.bioscada.apps.biotracks.TrackDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); hasCamera = getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); photoUri = savedInstanceState != null ? (Uri) savedInstanceState.getParcelable(PHOTO_URI_KEY) : null; hasPhoto = savedInstanceState != null ? savedInstanceState.getBoolean(HAS_PHOTO_KEY, false) : false; myTracksProviderUtils = MyTracksProviderUtils.Factory.get(this); handleIntent(getIntent());/*from w ww .j a v a 2 s . c o m*/ sharedPreferences = getSharedPreferences(Constants.SETTINGS_NAME, Context.MODE_PRIVATE); trackRecordingServiceConnection = new TrackRecordingServiceConnection(this, bindChangedCallback); trackDataHub = TrackDataHub.newInstance(this); tabHost = (TabHost) findViewById(android.R.id.tabhost); tabHost.setup(); viewPager = (ViewPager) findViewById(R.id.pager); tabsAdapter = new TabsAdapter(this, tabHost, viewPager); TabSpec mapTabSpec = tabHost.newTabSpec(MyTracksMapFragment.MAP_FRAGMENT_TAG).setIndicator( getString(R.string.track_detail_map_tab), getResources().getDrawable(R.drawable.ic_tab_map)); tabsAdapter.addTab(mapTabSpec, MyTracksMapFragment.class, null); if (PreferencesUtils.getBoolean(this, R.string.chart_show_pacer_key, PreferencesUtils.CHART_SHOW_PACER_DEFAULT)) { TabSpec chartAndPacerTabSpec = tabHost.newTabSpec(ChartAndPacerFragment.CHART_AND_PACER_FRAGMENT_TAG) .setIndicator(getString(R.string.track_detail_chart_and_pacer_tab), getResources().getDrawable(R.drawable.ic_tab_chart)); tabsAdapter.addTab(chartAndPacerTabSpec, ChartAndPacerFragment.class, null); } TabSpec chartTabSpec = tabHost.newTabSpec(ChartFragment.CHART_FRAGMENT_TAG).setIndicator( getString(R.string.track_detail_chart_tab), getResources().getDrawable(R.drawable.ic_tab_chart)); tabsAdapter.addTab(chartTabSpec, ChartFragment.class, null); TabSpec statsTabSpec = tabHost.newTabSpec(StatsFragment.STATS_FRAGMENT_TAG).setIndicator( getString(R.string.track_detail_stats_tab), getResources().getDrawable(R.drawable.ic_tab_stats)); tabsAdapter.addTab(statsTabSpec, StatsFragment.class, null); TabSpec pacerTabSpec = tabHost.newTabSpec(PacerFragment.PACER_FRAGMENT_TAG).setIndicator( getString(R.string.track_detail_pacer_tab), getResources().getDrawable(R.drawable.ic_tab_pacer)); tabsAdapter.addTab(pacerTabSpec, PacerFragment.class, null); if (savedInstanceState != null) { tabHost.setCurrentTabByTag(savedInstanceState.getString(CURRENT_TAB_TAG_KEY)); } // Set the background after all three tabs are added ApiAdapterFactory.getApiAdapter().setTabBackground(tabHost.getTabWidget()); trackController = new TrackController(this, trackRecordingServiceConnection, false, recordListener, stopListener); }