List of usage examples for android.os Bundle putParcelable
public void putParcelable(@Nullable String key, @Nullable Parcelable value)
From source file:com.csipsimple.plugins.twvoip.CallHandler.java
@Override public void onReceive(Context context, Intent intent) { if (ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { PendingIntent pendingIntent = null; // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, ""); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (!TextUtils.isEmpty(number) && !TextUtils.isEmpty(user) && !TextUtils.isEmpty(nbr) && !TextUtils.isEmpty(pwd)) { // Build pending intent Intent i = new Intent(ACTION_DO_TWVOIP_CALL); i.setClass(context, getClass()); i.putExtra(Intent.EXTRA_PHONE_NUMBER, number); pendingIntent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); // = PendingIntent.getActivity(context, 0, i, 0); }//from w w w. j a va2 s .c om // Build icon Bitmap bmp = null; Drawable icon = context.getResources().getDrawable(R.drawable.icon); BitmapDrawable bd = ((BitmapDrawable) icon); bmp = bd.getBitmap(); // Build the result for the row (label, icon, pending intent, and // excluded phone number) Bundle results = getResultExtras(true); if (pendingIntent != null) { results.putParcelable(Intent.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); } results.putString(Intent.EXTRA_TITLE, "12voip WebCallback"); if (bmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, bmp); } // DO *NOT* exclude from next tel: intent cause we use a http method // results.putString(Intent.EXTRA_PHONE_NUMBER, number); } else if (ACTION_DO_TWVOIP_CALL.equals(intent.getAction())) { // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_12VOIP_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_12VOIP_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_12VOIP_NBR, ""); // params List<NameValuePair> params = new LinkedList<NameValuePair>(); params.add(new BasicNameValuePair("username", user)); params.add(new BasicNameValuePair("password", pwd)); params.add(new BasicNameValuePair("from", nbr)); params.add(new BasicNameValuePair("to", number)); String paramString = URLEncodedUtils.format(params, "utf-8"); String requestURL = "https://www.12voip.com//myaccount/makecall.php?" + paramString; HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(requestURL); // Create a response handler HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet); Log.d(THIS_FILE, "response code is " + httpResponse.getStatusLine().getStatusCode()); if (httpResponse.getStatusLine().getStatusCode() == 200) { InputStreamReader isr = new InputStreamReader(httpResponse.getEntity().getContent()); BufferedReader br = new BufferedReader(isr); String line; String fullReply = ""; boolean foundSuccess = false; while ((line = br.readLine()) != null) { if (!TextUtils.isEmpty(line) && line.toLowerCase().contains("success")) { showToaster(context, "Success... wait a while you'll called back"); foundSuccess = true; break; } if (!TextUtils.isEmpty(line)) { fullReply = fullReply.concat(line); } } if (!foundSuccess) { showToaster(context, "Error : server error : " + fullReply); } } else { showToaster(context, "Error : invalid request " + httpResponse.getStatusLine().getStatusCode()); } } catch (ClientProtocolException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } catch (IOException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } } }
From source file:com.android.gallery3d.gadget.WidgetConfigure.java
protected void onSaveInstanceStates(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(KEY_PICKED_ITEM, mPickedItem); }
From source file:com.seatgeek.placesautocompletedemo.MainFragment.java
public static MainFragment newInstance(LatLng location) { MainFragment f = new MainFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_LOCATION, location); f.setArguments(args);/*from www. ja v a 2s . co m*/ return f; }
From source file:com.android.messaging.ui.FixedViewPagerAdapter.java
@Override public Parcelable saveState() { // The paged views in the view pager gets created and destroyed as the user scrolls through // them. By default, only the pages to the immediate left and right of the current visible // page are realized. Moreover, if the activity gets destroyed and recreated, the pages are // automatically destroyed. Therefore, in order to preserve transient page UI states that // are not persisted in the DB we'd like to store them in a Bundle when views get // destroyed. When the views get recreated, we rehydrate them by passing them the saved // data. When the activity gets destroyed, it invokes saveState() on this adapter to // add this saved Bundle to the overall saved instance state. final Bundle savedViewHolderState = new Bundle(Factory.get().getApplicationContext().getClassLoader()); for (int i = 0; i < mViewHolders.length; i++) { final Parcelable pageState = getViewHolder(i).saveState(); savedViewHolderState.putParcelable(getInstanceStateKeyForPage(i), pageState); }//w ww. ja v a 2s . c om return savedViewHolderState; }
From source file:com.csipsimple.plugins.betamax.CallHandlerWeb.java
@Override public void onReceive(Context context, Intent intent) { if (Utils.ACTION_GET_PHONE_HANDLERS.equals(intent.getAction())) { PendingIntent pendingIntent = null; // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_TW_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_TW_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_TW_NBR, ""); String provider = prefs.getString(CallHandlerConfig.KEY_TW_PROVIDER, ""); // We must handle that clean way cause when call just to // get the row in account list expect this to reply correctly if (!TextUtils.isEmpty(number) && !TextUtils.isEmpty(user) && !TextUtils.isEmpty(nbr) && !TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(provider)) { // Build pending intent Intent i = new Intent(ACTION_DO_WEB_CALL); i.setClass(context, getClass()); i.putExtra(Intent.EXTRA_PHONE_NUMBER, number); pendingIntent = PendingIntent.getBroadcast(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); }// ww w . j a va 2 s . co m // Build icon Bitmap bmp = Utils.getBitmapFromResource(context, R.drawable.icon_web); // Build the result for the row (label, icon, pending intent, and // excluded phone number) Bundle results = getResultExtras(true); if (pendingIntent != null) { results.putParcelable(Utils.EXTRA_REMOTE_INTENT_TOKEN, pendingIntent); } // Text for the row String providerName = ""; Resources r = context.getResources(); if (!TextUtils.isEmpty(provider)) { String[] arr = r.getStringArray(R.array.provider_values); String[] arrEntries = r.getStringArray(R.array.provider_entries); int i = 0; for (String prov : arr) { if (prov.equalsIgnoreCase(provider)) { providerName = arrEntries[i]; break; } i++; } } results.putString(Intent.EXTRA_TITLE, providerName + " " + r.getString(R.string.web_callback)); Log.d(THIS_FILE, "icon is " + bmp); if (bmp != null) { results.putParcelable(Intent.EXTRA_SHORTCUT_ICON, bmp); } // DO *NOT* exclude from next tel: intent cause we use a http method // results.putString(Intent.EXTRA_PHONE_NUMBER, number); } else if (ACTION_DO_WEB_CALL.equals(intent.getAction())) { // Extract infos from intent received String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER); // Extract infos from settings SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String user = prefs.getString(CallHandlerConfig.KEY_TW_USER, ""); String pwd = prefs.getString(CallHandlerConfig.KEY_TW_PWD, ""); String nbr = prefs.getString(CallHandlerConfig.KEY_TW_NBR, ""); String provider = prefs.getString(CallHandlerConfig.KEY_TW_PROVIDER, ""); // params List<NameValuePair> params = new LinkedList<NameValuePair>(); params.add(new BasicNameValuePair("username", user)); params.add(new BasicNameValuePair("password", pwd)); params.add(new BasicNameValuePair("from", nbr)); params.add(new BasicNameValuePair("to", number)); String paramString = URLEncodedUtils.format(params, "utf-8"); String requestURL = "https://www." + provider + "/myaccount/makecall.php?" + paramString; HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(requestURL); // Create a response handler HttpResponse httpResponse; try { httpResponse = httpClient.execute(httpGet); Log.d(THIS_FILE, "response code is " + httpResponse.getStatusLine().getStatusCode()); if (httpResponse.getStatusLine().getStatusCode() == 200) { InputStreamReader isr = new InputStreamReader(httpResponse.getEntity().getContent()); BufferedReader br = new BufferedReader(isr); String line; String fullReply = ""; boolean foundSuccess = false; while ((line = br.readLine()) != null) { if (!TextUtils.isEmpty(line) && line.toLowerCase().contains("success")) { showToaster(context, "Success... wait a while you'll called back"); foundSuccess = true; break; } if (!TextUtils.isEmpty(line)) { fullReply = fullReply.concat(line); } } if (!foundSuccess) { showToaster(context, "Error : server error : " + fullReply); } } else { showToaster(context, "Error : invalid request " + httpResponse.getStatusLine().getStatusCode()); } } catch (ClientProtocolException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } catch (IOException e) { showToaster(context, "Error : " + e.getLocalizedMessage()); } } }
From source file:com.cooperok.socialuser.fb.FbAccount.java
@Override public void postImage(Bitmap image, final PostImageCallback callback) { final Session session = Session.getActiveSession(); if (session != null && session.isOpened()) { Bundle params = new Bundle(); params.putString("message", ""); params.putParcelable("picture", image); params.putParcelable("source", image); Request request = new Request(Session.getActiveSession(), "me/photos", params, HttpMethod.POST); request.setCallback(new Request.Callback() { @Override//from w w w . j av a2 s.c o m public void onCompleted(Response response) { if (response.getError() == null) { String postId = null; try { postId = response.getGraphObject().getInnerJSONObject().getString("post_id"); } catch (JSONException e) { } callback.onImagePosted(FbAccount.this, postId); } else { callback.onImagePostedError(FbAccount.this); } } }); request.executeAsync(); } }
From source file:com.artemchep.horario.ui.fragments.master.TeachersFragment.java
@Override public void onItemClick(@NonNull View view, @NonNull Teacher item) { super.onItemClick(view, item); Bundle args = new Bundle(); args.putBoolean(ModelFragment.EXTRA_EDITABLE, mEditable); args.putString(ModelFragment.EXTRA_TIMETABLE_PATH, mTimetablePath); args.putParcelable(MooDetailsFragment.EXTRA_MODEL, item); Fragment fragment = new TeacherDetailsFragment(); fragment.setArguments(args);/*from w w w . j a v a2 s .c om*/ MainActivity activity = (MainActivity) getActivity(); activity.navigateDetailsFrame(fragment); }
From source file:ca.rmen.android.scrumchatter.team.Teams.java
/** * Retrieve the currently selected team. Show a dialog with a text input to rename this team. Validate that the new name doesn't correspond to any other * existing team. Upon pressing ok, rename the current team. *//*from w w w . jav a2 s.c om*/ public void promptRenameTeam(final Team team) { Log.v(TAG, "promptRenameTeam, team=" + team); if (team != null) { // Show a dialog to input a new team name for the current team. Bundle extras = new Bundle(1); extras.putParcelable(EXTRA_TEAM_URI, team.teamUri); extras.putString(EXTRA_TEAM_NAME, team.teamName); DialogFragmentFactory.showInputDialog(mActivity, mActivity.getString(R.string.action_team_rename), mActivity.getString(R.string.hint_team_name), team.teamName, TeamNameValidator.class, R.id.action_team_rename, extras); } }
From source file:com.cerema.cloud2.ui.preview.FileDownloadFragment.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(FileDownloadFragment.EXTRA_FILE, getFile()); outState.putParcelable(FileDownloadFragment.EXTRA_ACCOUNT, mAccount); outState.putBoolean(FileDownloadFragment.EXTRA_ERROR, mError); }
From source file:de.lebenshilfe_muenster.uk_gebaerden_muensterland.activities.MainActivity.java
private void showSignVideo(Sign sign) { Log.d(TAG, "showSignVideo() " + hashCode()); final Intent intent = new Intent(this, LevelOneActivity.class); final Bundle bundle = new Bundle(); bundle.putString(LevelOneActivity.FRAGMENT_TO_SHOW, SignVideoFragment.class.getSimpleName()); bundle.putParcelable(SignVideoFragment.SIGN_TO_SHOW, sign); intent.putExtra(LevelOneActivity.EXTRA, bundle); startActivity(intent);//from w w w .ja v a 2 s . c o m }