List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:com.coderming.weatherwatch.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WearableProxy.getInstance().initiate(this); // watch related. mLocation = com.coderming.weatherwatch.Utility.getPreferredLocation(this); Uri contentUri = getIntent() != null ? getIntent().getData() : null; setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/* ww w . j a va 2 s . c o m*/ getSupportActionBar().setDisplayShowTitleEnabled(false); if (findViewById(R.id.weather_detail_container) != null) { // The detail container view will be present only in the large-screen layouts // (res/layout-sw600dp). If this view is present, then the activity should be // in two-pane mode. mTwoPane = true; // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. if (savedInstanceState == null) { DetailFragment fragment = new DetailFragment(); if (contentUri != null) { Bundle args = new Bundle(); args.putParcelable(DetailFragment.DETAIL_URI, contentUri); fragment.setArguments(args); } getSupportFragmentManager().beginTransaction() .replace(R.id.weather_detail_container, fragment, DETAILFRAGMENT_TAG).commit(); } } else { mTwoPane = false; getSupportActionBar().setElevation(0f); } ForecastFragment forecastFragment = ((ForecastFragment) getSupportFragmentManager() .findFragmentById(R.id.fragment_forecast)); forecastFragment.setUseTodayLayout(!mTwoPane); if (contentUri != null) { forecastFragment.setInitialSelectedDate(WeatherContract.WeatherEntry.getDateFromUri(contentUri)); } SunshineSyncAdapter.initializeSyncAdapter(this); // If Google Play Services is up to date, we'll want to register GCM. If it is not, we'll // skip the registration and this device will not receive any downstream messages from // our fake server. Because weather alerts are not a core feature of the app, this should // not affect the behavior of the app, from a user perspective. if (checkPlayServices()) { // Because this is the initial creation of the app, we'll want to be certain we have // a token. If we do not, then we will start the IntentService that will register this // application with GCM. SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean sentToken = sharedPreferences.getBoolean(SENT_TOKEN_TO_SERVER, false); if (!sentToken) { Intent intent = new Intent(this, RegistrationIntentService.class); startService(intent); } } // initialize watch data TodayWeatherBrief weatherBrief = TodayWeatherBrief.getTodayWeather(this); if (weatherBrief != null) { Utility.notifyWatchWeatherChanged(this, weatherBrief); Utility.notifyWatciUnitChanged(this); } }
From source file:com.bw.myapplication.ui.fragment.VideosListFragment.java
@Override public void navigateToNewsDetail(int position, VideosListEntity entity) { Bundle extras = new Bundle(); extras.putParcelable(PlayerActivity.INTENT_VIDEO_EXTRAS, entity); readyGo(PlayerActivity.class, extras); }
From source file:edu.mit.mobile.android.locast.accounts.AbsLocastAuthenticator.java
/** * {@inheritDoc}//from w w w.j a va 2 s .c om */ @Override public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle loginOptions) { if (!authTokenType.equals(getAuthTokenType())) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType"); return result; } final AccountManager am = AccountManager.get(mContext); final String password = am.getPassword(account); if (password != null) { final Bundle accountData = onlineConfirmPassword(account, password); if (accountData != null) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); result.putString(AccountManager.KEY_ACCOUNT_TYPE, getAccountType()); result.putString(AccountManager.KEY_AUTHTOKEN, password); return result; } } // the password was missing or incorrect, return an Intent to an // Activity that will prompt the user for the password. final Intent intent = getAuthenticator(mContext); intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_USERNAME, account.name); intent.putExtra(AbsLocastAuthenticatorActivity.EXTRA_AUTHTOKEN_TYPE, authTokenType); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); final Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); return bundle; }
From source file:edu.mit.mobile.android.locast.accounts.Authenticator.java
/** * {@inheritDoc}/*from w w w . j a v a 2 s . co m*/ */ @Override public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle loginOptions) { if (!authTokenType.equals(AuthenticationService.AUTHTOKEN_TYPE)) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ERROR_MESSAGE, "invalid authTokenType"); return result; } final AccountManager am = AccountManager.get(mContext); final String password = am.getPassword(account); if (password != null) { final Bundle accountData = onlineConfirmPassword(account, password); if (accountData != null) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); result.putString(AccountManager.KEY_ACCOUNT_TYPE, AuthenticationService.ACCOUNT_TYPE); result.putString(AccountManager.KEY_AUTHTOKEN, password); return result; } } // the password was missing or incorrect, return an Intent to an // Activity that will prompt the user for the password. final Intent intent = new Intent(mContext, AuthenticatorActivity.class); intent.putExtra(AuthenticatorActivity.EXTRA_USERNAME, account.name); intent.putExtra(AuthenticatorActivity.EXTRA_AUTHTOKEN_TYPE, authTokenType); intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response); final Bundle bundle = new Bundle(); bundle.putParcelable(AccountManager.KEY_INTENT, intent); return bundle; }
From source file:ca.uwaterloo.magic.goodhikes.AddMilestoneDialogFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); try {/* w ww.j av a2 s . c o m*/ Bitmap bitmap = ((BitmapDrawable) previewImage.getDrawable()).getBitmap(); outState.putParcelable("image", bitmap); } catch (NullPointerException e) { Log.d(LOG_TAG, "Thread: " + Thread.currentThread().getId() + "; No image stored in ImageView"); } }
From source file:net.reichholf.dreamdroid.fragment.TimerListFragment.java
@Override public void onSaveInstanceState(Bundle outState) { outState.putParcelable("timer", mTimer); super.onSaveInstanceState(outState); }
From source file:fiskinfoo.no.sintef.fiskinfoo.MyToolsFragment.java
/** * Use this factory method to create a new instance of * this fragment using the provided parameters. * * @param user The user instance./*from w w w .j a v a 2 s . c om*/ * @return A new instance of fragment MyToolsFragment. */ public static MyToolsFragment newInstance(User user) { MyToolsFragment fragment = new MyToolsFragment(); Bundle args = new Bundle(); args.putParcelable(USER_PARAM, user); fragment.setArguments(args); return fragment; }
From source file:cn.refactor.ultraindicator.lib.UltraIndicatorView.java
@Override protected Parcelable onSaveInstanceState() { Bundle bundle = new Bundle(); bundle.putParcelable(KEY_INSTANCE_STATE, super.onSaveInstanceState()); bundle.putInt(KEY_INSTANCE_STATE, mCheckedPosition); return bundle; }
From source file:com.chrismorais.android.sunshine.app.MainActivity.java
@Override public void onItemSelected(Uri contentUri) { if (mTwoPane) { // In two-pane mode, show the detail view in this activity by // adding or replacing the detail fragment using a // fragment transaction. Bundle args = new Bundle(); args.putParcelable(DetailFragment.DETAIL_URI, contentUri); DetailFragment fragment = new DetailFragment(); fragment.setArguments(args);// ww w. j a v a 2 s . c o m getSupportFragmentManager().beginTransaction() .replace(R.id.weather_detail_container, fragment, DETAILFRAGMENT_TAG).commit(); } else { Intent intent = new Intent(this, DetailActivity.class).setData(contentUri); ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation(this); ActivityCompat.startActivity(this, intent, activityOptions.toBundle()); } }