List of usage examples for android.os Bundle getByteArray
@Override @Nullable public byte[] getByteArray(@Nullable String key)
From source file:org.hopestarter.wallet.ui.RequestCoinsFragment.java
private void restoreInstanceState(final Bundle savedInstanceState) { address = new Address(Constants.NETWORK_PARAMETERS, savedInstanceState.getByteArray("receive_address")); }
From source file:com.frostwire.android.gui.dialogs.HandpickedTorrentDownloadDialog.java
@Override protected void initComponents(Dialog dlg, Bundle savedInstanceState) { byte[] torrentInfoData; Bundle arguments = getArguments(); if (this.torrentInfo == null && arguments != null && (torrentInfoData = arguments.getByteArray(BUNDLE_KEY_TORRENT_INFO_DATA)) != null) { torrentInfo = TorrentInfo.bdecode(torrentInfoData); magnetUri = arguments.getString(BUNDLE_KEY_MAGNET_URI, null); torrentFetcherDownloadTokenId = arguments.getLong(BUNDLE_KEY_TORRENT_FETCHER_DOWNLOAD_TOKEN_ID); if (torrentFetcherDownloadTokenId != -1) { setOnCancelListener(new OnCancelDownloadsClickListener(this)); }// ww w . ja v a 2 s . c o m setOnYesListener(new OnStartDownloadsClickListener(dlg.getContext(), this)); } super.initComponents(dlg, savedInstanceState); }
From source file:com.ntsync.android.sync.activities.CreatePwdProgressDialog.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); AccountManager accountManager = AccountManager.get(getActivity()); Bundle args = getArguments(); String mUsername = args.getString(KeyPasswordActivity.PARAM_USERNAME); byte[] pwdSalt = args.getByteArray(KeyPasswordActivity.PARAM_SALT); Account account = new Account(mUsername, Constants.ACCOUNT_TYPE); String pwd = args.getString(PARAM_PWD); byte[] pwdCheck = args.getByteArray(KeyPasswordActivity.PARAM_CHECK); // Retain to keep Task during conf changes setRetainInstance(true);//from w ww. j a v a2 s . co m setCancelable(false); if (pwd == null) { createTask = new CreatePwdTask(account, accountManager, pwdSalt); } else { createTask = new RecreateKeyTask(account, accountManager, pwdSalt, pwdCheck, pwd); } createTask.execute(); }
From source file:com.cnm.cnmrc.fragment.vodtvch.VodDetail.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View layout = inflater.inflate(R.layout.search_vod_detail, container, false); mContext = getActivity();// ww w . j a v a 2s .com isFirstDepth = getArguments().getBoolean("isFirstDepth"); Bundle bundle = getArguments().getBundle("bundle"); vodAssetId = bundle.getString("vodAssetId"); byte[] logoImage = bundle.getByteArray("logoImg"); String title = bundle.getString("title"); String hd = bundle.getString("hd"); String grade = bundle.getString("grade"); String director = bundle.getString("director"); String actor = bundle.getString("actor"); String price = bundle.getString("price"); String contents = bundle.getString("contents"); Bitmap bmp = BitmapFactory.decodeByteArray(logoImage, 0, logoImage.length); ImageView logoImg = (ImageView) layout.findViewById(R.id.logo_img); logoImg.setImageBitmap(bmp); if (title != null) ((TextView) layout.findViewById(R.id.title)).setText(title); if (hd != null) { if (hd.equalsIgnoreCase("yes")) ((ImageView) layout.findViewById(R.id.hd_icon)).setVisibility(View.VISIBLE); } if (grade != null) ((ImageView) layout.findViewById(R.id.grade_icon)).setBackgroundResource(Util.getGrade(grade)); if (director != null) ((TextView) layout.findViewById(R.id.director_name)).setText(" " + director); if (actor != null) ((TextView) layout.findViewById(R.id.actor_name)).setText(" " + actor); if (grade != null) ((TextView) layout.findViewById(R.id.grade_text)).setText(" " + grade); if (price != null) ((TextView) layout.findViewById(R.id.price_amount)).setText(" " + price); if (contents != null) ((TextView) layout.findViewById(R.id.contents)).setText(contents); // vod ImageButton vod = (ImageButton) layout.findViewById(R.id.vod_zzim); vod.setOnClickListener(this); // tv? ImageButton tv = (ImageButton) layout.findViewById(R.id.vod_tv_watching); tv.setOnClickListener(this); return layout; }
From source file:com.facebook.android.FBUtil.java
/** * Connect to an HTTP URL and return the response as a string. * * Note that the HTTP method override is used on non-GET requests. (i.e. * requests are made as "POST" with method specified in the body). * * @param url - the resource to open: must be a welformed URL * @param method - the HTTP method to use ("GET", "POST", etc.) * @param params - the query parameter for the URL (e.g. access_token=foo) * @return the URL contents as a String// w w w . jav a2 s. c o m * @throws MalformedURLException - if the URL format is invalid * @throws IOException - if a network problem occurs */ public static String openUrl(String url, String method, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os; // Try to get filename key String filename = params.getString("filename"); // If found if (filename != null) { // Remove from params params.remove("filename"); } if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Log.d("Facebook-FBUtil", method + " URL: " + url); HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " FacebookAndroidSDK"); if (!method.equals("GET")) { Bundle dataparams = new Bundle(); for (String key : params.keySet()) { if (params.getByteArray(key) != null) { dataparams.putByteArray(key, params.getByteArray(key)); } } // use method override if (!params.containsKey("method")) { params.putString("method", method); } if (params.containsKey("access_token")) { String decoded_token = URLDecoder.decode(params.getString("access_token")); params.putString("access_token", decoded_token); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((encodePostBody(params, strBoundary)).getBytes()); os.write((endLine + "--" + strBoundary + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; filename=\"" + ((filename) != null ? filename : key) + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + strBoundary + endLine).getBytes()); } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = read(conn.getErrorStream()); } return response; }
From source file:cn.bidaround.ytcore.kaixin.KaixinUtil.java
/** * ??http//from www .j a v a2 s. co m * * @param context * * @param requestURL * ?? * @param httpMethod * GET POST * @param params * key-value??key???value???Stringbyte[] * @param photos * key-value??? keyfilename * value????InputStreambyte[] * ?InputStreamopenUrl? * @return ?JSON * @throws IOException */ public static String openUrl(Context context, String requestURL, String httpMethod, Bundle params, Map<String, Object> photos) throws IOException { OutputStream os; if (httpMethod.equals("GET")) { requestURL = requestURL + "?" + encodeUrl(params); } URL url = new URL(requestURL); HttpsURLConnection conn = (HttpsURLConnection) getConnection(context, url); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " KaixinAndroidSDK"); conn.setDoInput(true); conn.setUseCaches(false); conn.setRequestProperty("Connection", "close"); conn.setRequestProperty("Charsert", "UTF-8"); if (!httpMethod.equals("GET")) { Bundle dataparams = new Bundle(); // for (String key : params.keySet()) { // if (params.getByteArray(key) != null) { // dataparams.putByteArray(key, params.getByteArray(key)); // } // } String BOUNDARY = KaixinUtil.md5(String.valueOf(System.currentTimeMillis())); // ? String endLine = "\r\n"; conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDARY); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + BOUNDARY + endLine).getBytes()); os.write((encodePostBody(params, BOUNDARY)).getBytes()); os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); if (!dataparams.isEmpty()) { for (String key : dataparams.keySet()) { os.write(("Content-Disposition: form-data; name=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes()); os.write(dataparams.getByteArray(key)); os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); } } if (photos != null && !photos.isEmpty()) { for (String key : photos.keySet()) { Object obj = photos.get(key); if (obj instanceof InputStream) { InputStream is = (InputStream) obj; try { os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\"" + endLine).getBytes()); os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes()); byte[] data = new byte[UPLOAD_BUFFER_SIZE]; int nReadLength = 0; while ((nReadLength = is.read(data)) != -1) { os.write(data, 0, nReadLength); } os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); } finally { try { if (null != is) { is.close(); } } catch (Exception e) { Log.e(LOG_TAG, "Exception on closing input stream", e); } } } else if (obj instanceof byte[]) { byte[] byteArray = (byte[]) obj; os.write(("Content-Disposition: form-data; name=\"pic\";filename=\"" + key + "\"" + endLine) .getBytes()); os.write(("Content-Type:application/octet-stream\r\n\r\n").getBytes()); os.write(byteArray); os.write((endLine + "--" + BOUNDARY + endLine).getBytes()); } else { Log.e(LOG_TAG, "?"); } } } os.flush(); } String response = ""; try { response = read(conn.getInputStream()); } catch (FileNotFoundException e) { response = read(conn.getErrorStream()); } return response; }
From source file:org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); mDataUri = args.getParcelable(ARG_DATA_URI); mLidRank = args.getInt(ARG_LID_RANK); mIsSecret = args.getBoolean(ARG_IS_SECRET); mFingerprint = args.getByteArray(ARG_FINGERPRINT); mContext = getActivity();/*from w w w. j a va 2 s .c o m*/ getLoaderManager().initLoader(LOADER_ID_LINKED_ID, null, this); }
From source file:io.imoji.sdk.editor.fragment.ImojiEditorFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); mBitmapRetainerFragment = findOrCreateRetainedFragment(); if (savedInstanceState != null) { mPreScaleBitmap = mBitmapRetainerFragment.mPreScaledBitmap; mStateData = savedInstanceState.getByteArray(EDITOR_STATE_BUNDLE_ARG_KEY); if (mStateData != null) { mIGEditorView.deserialize(mStateData); }/*from w ww . ja va 2s.c o m*/ if (mIGEditorView.canUndo()) { mUndoButton.setVisibility(View.VISIBLE); } } }
From source file:com.dongbang.yutian.activity.CommonScanActivity.java
/** * *//*from w ww .j a v a2 s. c o m*/ public void scanResult(Result rawResult, Bundle bundle) { //????????????reScan() //scanManager.reScan(); // Toast.makeText(that, "result="+rawResult.getText(), Toast.LENGTH_LONG).show(); if (!scanManager.isScanning()) { //????? //??? rescan.setVisibility(View.VISIBLE); scan_image.setVisibility(View.VISIBLE); Bitmap barcode = null; byte[] compressedBitmap = bundle.getByteArray(DecodeThread.BARCODE_BITMAP); if (compressedBitmap != null) { barcode = BitmapFactory.decodeByteArray(compressedBitmap, 0, compressedBitmap.length, null); barcode = barcode.copy(Bitmap.Config.ARGB_8888, true); } scan_image.setImageBitmap(barcode); } rescan.setVisibility(View.VISIBLE); scan_image.setVisibility(View.VISIBLE); tv_scan_result.setVisibility(View.VISIBLE); tv_scan_result.setText("" + rawResult.getText()); // Toast.makeText(this,""+rawResult.getText(),Toast.LENGTH_SHORT).show(); // result=rawResult.getText(); ScanResult.setResult(rawResult.getText()); finish(); Intent it = new Intent(this, ProductInfoActivity.class); startActivity(it); }