List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:cochrane343.journal.MainActivity.java
@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); monthlyExpensesPagerAdapter = new MonthlyExpensesPagerAdapter(getSupportFragmentManager()); viewPager = (ViewPager) findViewById(R.id.main_activity_view_pager); viewPager.setAdapter(monthlyExpensesPagerAdapter); if (savedInstanceState != null) { final Parcelable monthlyPagerAdapterState = savedInstanceState .getParcelable(BUNDLE_KEY_MONTHLY_PAGER_ADAPTER_STATE); monthlyExpensesPagerAdapter.restoreState(monthlyPagerAdapterState, getClassLoader()); } else {//from w w w. j a va 2 s. c o m viewPager.setCurrentItem(DateTimeHelper.getMonthsSinceEpoch()); } }
From source file:com.anjlab.android.iab.v3.BillingProcessor.java
private boolean purchase(Activity activity, String productId, String purchaseType) { if (!isInitialized() || TextUtils.isEmpty(productId) || TextUtils.isEmpty(purchaseType)) return false; try {/*from w w w .ja v a2s.c o m*/ String purchasePayload = purchaseType + ":" + UUID.randomUUID().toString(); savePurchasePayload(purchasePayload); Bundle bundle = billingService.getBuyIntent(Constants.GOOGLE_API_VERSION, contextPackageName, productId, purchaseType, purchasePayload); if (bundle != null) { int response = bundle.getInt(Constants.RESPONSE_CODE); if (response == Constants.BILLING_RESPONSE_RESULT_OK) { PendingIntent pendingIntent = bundle.getParcelable(Constants.BUY_INTENT); if (activity != null) activity.startIntentSenderForResult(pendingIntent.getIntentSender(), PURCHASE_FLOW_REQUEST_CODE, new Intent(), 0, 0, 0); else if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_LOST_CONTEXT, null); } else if (response == Constants.BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) { if (!isPurchased(productId) && !isSubscribed(productId)) loadOwnedPurchasesFromGoogle(); if (eventHandler != null) { TransactionDetails details = getPurchaseTransactionDetails(productId); if (details == null) details = getSubscriptionTransactionDetails(productId); eventHandler.onProductPurchased(productId, details); } } else if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_FAILED_TO_INITIALIZE_PURCHASE, null); } return true; } catch (Exception e) { Log.e(LOG_TAG, e.toString()); } return false; }
From source file:com.appsimobile.appsii.module.weather.WeatherActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AppInjector.inject(this); if (savedInstanceState != null) { mBitmap = savedInstanceState.getParcelable("selected_image"); }/* w w w . j av a 2s. c om*/ String woeid = getIntent().getStringExtra(EXTRA_WOEID); if (woeid == null) { woeid = mSharedPreferences.getString(WeatherLoadingService.PREFERENCE_LAST_KNOWN_WOEID, null); } if (woeid == null) { woeid = mPreferenceHelper.getDefaultLocationWoeId(); } if (woeid == null) { // TODO: we need a default location. finish(); return; } mDisplayUnit = getIntent().getStringExtra(EXTRA_UNIT); mTimezone = getIntent().getStringExtra(EXTRA_TIME_ZONE); mWoeid = woeid; setContentView(R.layout.activity_weather_details); mBackgroundImage = (ImageView) findViewById(R.id.weather_background); mCurrentWeatherIcon = (ImageView) findViewById(R.id.current_weather); mTemperatureView = (TextView) findViewById(R.id.temperature); mLocationView = (TextView) findViewById(R.id.location); mConditionView = (TextView) findViewById(R.id.condition); mCurrentWeatherContainer = findViewById(R.id.current_weather_container); mMinTempView = (TextView) findViewById(R.id.temp_min); mMaxTempView = (TextView) findViewById(R.id.temp_max); mWindView = (TextView) findViewById(R.id.wind); mFeelsLikeView = (TextView) findViewById(R.id.feels_like); mRecyclerView = (RecyclerView) findViewById(R.id.recycler); mForecastHeader = (TextView) findViewById(R.id.forecast_header); mMinTempDrawable = mMinTempView.getCompoundDrawablesRelative()[0]; mMaxTempDrawable = mMaxTempView.getCompoundDrawablesRelative()[0]; BitmapDrawable windDrawable = (BitmapDrawable) mWindView.getCompoundDrawablesRelative()[0]; mWindDrawable = new SimpleRotateDrawable(getResources(), windDrawable.getBitmap()); mWindView.setCompoundDrawablesRelativeWithIntrinsicBounds(mWindDrawable, null, null, null); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mAdapter = new ForecastAdapter(mDisplayUnit); mRecyclerView.setAdapter(mAdapter); getLoaderManager().initLoader(1, null, new WeatherDataLoaderCallbacks()); }
From source file:edu.cmu.hcii.hangg.beeksbeacon.Fragments.ManageBeaconFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle b = this.getArguments(); beaconInstance = b.getParcelable("beaconInstance"); String accountName = b.getString("accountName"); client = new ProximityBeaconImpl(getActivity(), accountName); }
From source file:org.bwgz.quotation.activity.QuotationActivity.java
@Override public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) { Log.d(TAG, String.format("onCreateLoader - loaderID: %d bundle: %s", loaderID, bundle)); Loader<Cursor> loader = null; Uri uri = bundle.getParcelable(LOAD_URI); if (loaderID == LOADER_ID_QUTOATION) { loader = new CursorLoader(this, uri, new String[] { Quotation.QUOTATION }, null, null, null); } else if (loaderID == LOADER_ID_AUTHOR) { loader = new CursorLoader(this, Person.CONTENT_URI, null, authorsQuery, new String[] { Quotation.getId(uri) }, null); }/*w w w . j av a 2 s . c o m*/ Log.d(TAG, String.format("onCreateLoader - return loader: %s", loader)); return loader; }
From source file:com.hybris.mobile.lib.location.geofencing.service.GeofencingIntentService.java
/** * Handles incoming intents/*from ww w .j a v a2s. c o m*/ * * @param intent The Intent sent by Location Services. This Intent is provided to Location Services (inside a * PendingIntent) when you call addGeofences() */ @Override protected void onHandleIntent(Intent intent) { Log.i(TAG, "Geofencing event received"); GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent); // Check for errors if (geofencingEvent.hasError()) { Log.e(TAG, "Error with geofencing. Error Code: " + geofencingEvent.getErrorCode()); } else { // Get the type of transition (entry or leaving_geofence) int geofenceTransition = geofencingEvent.getGeofenceTransition(); Log.i(TAG, "Geofence transition type: " + geofenceTransition); // Test that a valid transition was reported if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER || geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { // Post a notification List<Geofence> geofences = geofencingEvent.getTriggeringGeofences(); if (geofences != null && !geofences.isEmpty()) { for (Geofence geofence : geofences) { Log.d(TAG, "Intent information: "); Bundle intentBundle = intent .getBundleExtra(GeofencingConstants.PREFIX_INTENT_BUNDLE + geofence.getRequestId()); if (intentBundle != null) { Log.d(TAG, "Bundle information: "); for (String key : intentBundle.keySet()) { Log.d(TAG, "Key: " + key + ". Value: " + intentBundle.get(key)); } sendNotification(geofence, (GeofenceObject.Notification) intentBundle.getParcelable( GeofencingConstants.PREFIX_INTENT_NOTIFICATION_TRANSITION + geofenceTransition), geofenceTransition); } else { Log.e(TAG, "No bundle found for geofence id " + geofence.getRequestId()); } } } else { Log.e(TAG, "No associated geofences found for transition " + geofenceTransition); } } else { // Log the error. Log.e(TAG, "Geofence transition not supported by the library. Details: " + geofenceTransition); } } }
From source file:com.android.deskclock.RingtonePickerDialogFragment.java
@Override public AlertDialog onCreateDialog(Bundle savedInstanceState) { final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.DialogTheme); final Bundle args = getArguments(); mRingtoneAdapter = new RingtoneAdapter(builder.getContext()) .addStaticRingtone(R.string.silent_ringtone_title, Utils.RINGTONE_SILENT) .addStaticRingtone(args.getInt(ARGS_KEY_DEFAULT_RINGTONE_TITLE), (Uri) args.getParcelable(ARGS_KEY_DEFAULT_RINGTONE_URI)); mDialog = builder.setTitle(args.getInt(ARGS_KEY_TITLE)) .setSingleChoiceItems(mRingtoneAdapter, -1, this /* listener */) .setPositiveButton(android.R.string.ok, this /* listener */) .setNegativeButton(android.R.string.cancel, null /* listener */).create(); return mDialog; }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.photoselection_activity); if (savedInstanceState != null) { mCurrentPhotoUri = savedInstanceState.getParcelable(KEY_CURRENT_PHOTO_URI); mSubActivityInProgress = savedInstanceState.getBoolean(KEY_SUB_ACTIVITY_IN_PROGRESS); }/*from ww w . j av a 2 s .c o m*/ // Pull data out of the intent. final Intent intent = getIntent(); mPhotoUri = intent.getParcelableExtra(PHOTO_URI); mState = (RawContactDeltaList) intent.getParcelableExtra(ENTITY_DELTA_LIST); mIsProfile = intent.getBooleanExtra(IS_PROFILE, false); mIsDirectoryContact = intent.getBooleanExtra(IS_DIRECTORY_CONTACT, false); mExpandPhoto = intent.getBooleanExtra(EXPAND_PHOTO, false); // Pull out photo expansion properties from resources mExpandedPhotoSize = getResources().getDimensionPixelSize(R.dimen.detail_contact_photo_expanded_size); mHeightOffset = getResources().getDimensionPixelOffset(R.dimen.expanded_photo_height_offset); mBackdrop = findViewById(R.id.backdrop); mPhotoView = (ImageView) findViewById(R.id.photo); mSourceBounds = intent.getSourceBounds(); // Fade in the background. animateInBackground(); // Dismiss the dialog on clicking the backdrop. mBackdrop.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); // Wait until the layout pass to show the photo, so that the source bounds will match up. SchedulingUtils.doAfterLayout(mBackdrop, new Runnable() { @Override public void run() { displayPhoto(); } }); }
From source file:net.mEmoZz.PopMovies.frags.DetailFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Bundle bundle = this.getArguments(); helper = new DBHelper(getActivity()); Configuration conf = getActivity().getResources().getConfiguration(); if (conf.smallestScreenWidthDp >= 600) { if (bundle != null) { movie = bundle.getParcelable("movie"); position = bundle.getInt("pos"); if (movie != null) { posterEndPoint = movie.getPoster(); backdropEndPoint = movie.getBackdrop(); overviewEndPoint = movie.getOverview(); dateEndPoint = movie.getDate(); voteEndPoint = movie.getVoteAvr(); titleEndPoint = movie.getTitle(); idEndpoint = movie.getId(); if (dateEndPoint.equals("")) { year = "Unknown"; } else { year = dateEndPoint.substring(0, 4); }/*from w w w.ja v a2 s. co m*/ if (titleEndPoint.equals("")) { titleEndPoint = "Not available."; } else { titleEndPoint = movie.getTitle(); } if (overviewEndPoint.equals("")) { overviewEndPoint = "No overview found."; } else { overviewEndPoint = movie.getOverview(); } } } } else { posterEndPoint = getActivity().getIntent().getExtras().getString("poster"); backdropEndPoint = getActivity().getIntent().getExtras().getString("backdrop"); overviewEndPoint = getActivity().getIntent().getExtras().getString("overview"); dateEndPoint = getActivity().getIntent().getExtras().getString("date"); voteEndPoint = getActivity().getIntent().getExtras().getString("vote"); titleEndPoint = getActivity().getIntent().getExtras().getString("title"); idEndpoint = getActivity().getIntent().getExtras().getString("id"); position = getActivity().getIntent().getExtras().getInt("position"); } boolean ifExist = helper.ifExist(idEndpoint); if (ifExist) { detailUnFav.setVisibility(VISIBLE); detailFav.setVisibility(GONE); } else { detailUnFav.setVisibility(GONE); detailFav.setVisibility(VISIBLE); } String posterUrl = Url.POSTERS_URL + "w342" + posterEndPoint; DisplayImageOptions mOptions = new DisplayImageOptions.Builder().cacheOnDisk(true).cacheInMemory(false) .displayer(new FadeInBitmapDisplayer(1500)).showImageOnFail(R.drawable.no_poster) .showImageForEmptyUri(R.drawable.no_poster).build(); ImageLoader.getInstance().displayImage(posterUrl, detailPoster, mOptions, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { Palette p = Palette.from(loadedImage).generate(); detailCard.setCardBackgroundColor(p.getVibrantColor(0)); if (p.getVibrantColor(0) == Color.TRANSPARENT) { detailCard.setCardBackgroundColor(p.getMutedColor(0)); } } }); String backdropUrl = Url.POSTERS_URL + "w780" + backdropEndPoint; if (conf.smallestScreenWidthDp >= 600) { ImageLoader.getInstance().displayImage(backdropUrl, tabBackdrop, mOptions, new SimpleImageLoadingListener() { @Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { Palette p = Palette.from(loadedImage).generate(); tabBackdrop.setBackgroundColor(p.getVibrantColor(0)); if (p.getVibrantColor(0) == Color.TRANSPARENT) { tabBackdrop.setBackgroundColor(p.getMutedColor(0)); } } }); detailDate.setText(year); detailTitle.setText(titleEndPoint); } else { detailDate.setText(dateEndPoint); } detailVoteAvr.setText(voteEndPoint); detailOverview.setText(overviewEndPoint); final ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(165); detailFav.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { adapter.notifyDataSetChanged(); detailFav.setVisibility(GONE); detailUnFav.startAnimation(animation); detailUnFav.setVisibility(VISIBLE); helper.insertRow(posterEndPoint, backdropEndPoint, idEndpoint, titleEndPoint, dateEndPoint, voteEndPoint, overviewEndPoint); } }); detailUnFav.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { adapter.notifyDataSetChanged(); detailUnFav.setVisibility(GONE); detailFav.startAnimation(animation); detailFav.setVisibility(VISIBLE); helper.deleteRow(idEndpoint); if (fav.isChecked()) { CoreAdapter.movies.remove(position); adapter.notifyItemRemoved(position); adapter.notifyDataSetChanged(); } } }); new DurationTask().execute(); trailsAdapter = new TrailersAdapter(trailers, getActivity()); new TrailersTask().execute(); revsAdapter = new ReviewsAdapter(reviews, getActivity()); new ReviewsTask().execute(); }
From source file:com.android.server.telecom.testapps.TestConnectionService.java
@Override public Connection onCreateOutgoingConnection(PhoneAccountHandle connectionManagerAccount, final ConnectionRequest originalRequest) { final Uri handle = originalRequest.getAddress(); String number = originalRequest.getAddress().getSchemeSpecificPart(); log("call, number: " + number); // Crash on 555-DEAD to test call service crashing. if ("5550340".equals(number)) { throw new RuntimeException("Goodbye, cruel world."); }//from w w w . j a v a 2 s. c o m Bundle extras = originalRequest.getExtras(); String gatewayPackage = extras.getString(TelecomManager.GATEWAY_PROVIDER_PACKAGE); Uri originalHandle = extras.getParcelable(TelecomManager.GATEWAY_ORIGINAL_ADDRESS); log("gateway package [" + gatewayPackage + "], original handle [" + originalHandle + "]"); final TestConnection connection = new TestConnection(false /* isIncoming */); setAddress(connection, handle); // If the number starts with 555, then we handle it ourselves. If not, then we // use a remote connection service. // TODO: Have a special phone number to test the account-picker dialog flow. if (number != null && number.startsWith("555")) { // Normally we would use the original request as is, but for testing purposes, we are // adding ".." to the end of the number to follow its path more easily through the logs. final ConnectionRequest request = new ConnectionRequest(originalRequest.getAccountHandle(), Uri.fromParts(handle.getScheme(), handle.getSchemeSpecificPart() + "..", ""), originalRequest.getExtras(), originalRequest.getVideoState()); connection.setVideoState(originalRequest.getVideoState()); /// M: only VideoCall addVideoProvider @{ if (originalRequest.getVideoState() == VideoProfile.STATE_BIDIRECTIONAL) { addVideoProvider(connection); } /// @} addCall(connection); connection.startOutgoing(); for (Connection c : getAllConnections()) { c.setOnHold(); } } else { log("Not a test number"); } return connection; }