List of usage examples for android.os Bundle getByteArray
@Override @Nullable public byte[] getByteArray(@Nullable String key)
From source file:org.schabi.terminightor.NightKillerActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_nightkiller); final Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(/*w ww. j a va 2 s . co m*/ WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); Bundle a = getIntent().getExtras(); alarmId = a.getLong(Alarm.ID); alarmLabel = a.getString(Alarm.NAME); expectedNfcId = a.getByteArray(Alarm.NFC_TAG_ID); innerWave = (ImageView) findViewById(R.id.inner_wave_alarm); outerWave = (ImageView) findViewById(R.id.outer_wave_alarm); alarmLabelView = (TextView) findViewById(R.id.alarm_label_alarm); alarmLabelView.setText(alarmLabel); nfcAdapter = NfcAdapter.getDefaultAdapter(this); ignoreNfcTagId = PreferenceManager.getDefaultSharedPreferences(this) .getBoolean(this.getString(R.string.ignoreNfcId), false); Log.d(TAG, Long.toString(alarmId)); }
From source file:org.sufficientlysecure.keychain.ui.CreateKeyYubiKeyImportFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = savedInstanceState != null ? savedInstanceState : getArguments(); mNfcFingerprints = args.getByteArray(ARG_FINGERPRINT); mNfcAid = args.getByteArray(ARG_AID); mNfcUserId = args.getString(ARG_USER_ID); byte[] fp = new byte[20]; ByteBuffer.wrap(fp).put(mNfcFingerprints, 0, 20); mNfcFingerprint = KeyFormattingUtils.convertFingerprintToHex(fp); }
From source file:com.bpd.facebook.Util.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//from w w w . j ava2s.co 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-Util", 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:com.amanmehara.programming.android.activities.ProgramActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_programs); setActionBar(R.id.toolbar, true);//from w ww. ja v a 2s. co m recyclerView = setRecyclerView(R.id.programs_recycler_view); Bundle bundle = getIntent().getExtras(); accessToken = bundle.getString("accessToken"); languageName = bundle.getString("languageName"); programsJson = bundle.getString("programs"); logoBlob = bundle.getByteArray("logoBlob"); setLanguageDatails(); try { setAdapter(new JSONArray(programsJson)); } catch (JSONException e) { Log.e(TAG, e.getMessage()); setAdapter(); } }
From source file:org.sufficientlysecure.keychain.ui.CreateYubiKeyImportResetFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = savedInstanceState != null ? savedInstanceState : getArguments(); mNfcFingerprints = args.getByteArray(ARG_FINGERPRINTS); mNfcAid = args.getByteArray(ARG_AID); mNfcUserId = args.getString(ARG_USER_ID); byte[] fp = new byte[20]; ByteBuffer.wrap(fp).put(mNfcFingerprints, 0, 20); mNfcFingerprint = KeyFormattingUtils.convertFingerprintToHex(fp); }
From source file:layout.BeaconTabFragment.java
/** * Updates slot information by pulling values from the bundle. These values can be: * - broadcast capabilities type: byte[] key: BROADCAST_CAPABILITIES * - radio tx power type: String key: TX_POWER * - adv tx power type: String key: ADV_POWER * - adv interval type: String key: ADV_INTERVAL * * @param bundle bundle containing all the information to be updated *///from w w w. j a va 2s.c o m public void updateInformation(Bundle bundle) { byte[] data = bundle.getByteArray(Constants.BROADCAST_CAPABILITIES); if (data != null) { capabilities = new BroadcastCapabilities(data); } String txPower = bundle.getString(Constants.TX_POWER); if (txPower != null) { this.txPower = txPower; } String advTxPower = bundle.getString(Constants.ADV_POWER); if (advTxPower != null) { this.advTxPower = advTxPower; } String advInterval = bundle.getString(Constants.ADV_INTERVAL); if (advInterval != null) { this.advInterval = advInterval; } }
From source file:org.sufficientlysecure.keychain.ui.CreateSecurityTokenImportResetFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = savedInstanceState != null ? savedInstanceState : getArguments(); mTokenFingerprints = args.getByteArray(ARG_FINGERPRINTS); mTokenAid = args.getByteArray(ARG_AID); mTokenUserId = args.getString(ARG_USER_ID); byte[] fp = new byte[20]; ByteBuffer.wrap(fp).put(mTokenFingerprints, 0, 20); mTokenFingerprint = KeyFormattingUtils.convertFingerprintToHex(fp); }
From source file:com.data.pack.Util.java
/** * Connect to an HTTP URL and return the response as a string. * /*from w w w.j av a2s .co m*/ * 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 * @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; if (method.equals("GET")) { url = url + "?" + encodeUrl(params); } Util.logd("Facebook-Util", 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=\"" + 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:com.grouzen.android.serenity.HttpConnection.java
private HttpResponse post(String url, Bundle params) throws ClientProtocolException, IOException { HttpPost method = new HttpPost(url); if (params != null) { try {//from w ww . ja v a2s . c o m if (mMultipartKey != null && mMultipartFileName != null) { ByteArrayBody byteArrayBody = new ByteArrayBody(params.getByteArray(mMultipartKey), mMultipartFileName); MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); Charset charset = Charset.forName(CHARSET); entity.addPart(mMultipartKey, byteArrayBody); params.remove(mMultipartKey); for (String k : params.keySet()) { entity.addPart(new FormBodyPart(k, new StringBody(params.getString(k), charset))); } method.setEntity(entity); } else { ArrayList<NameValuePair> entity = convertParams(params); method.setEntity(new UrlEncodedFormEntity(entity, CHARSET)); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } return execute(method); }
From source file:com.ravi.apps.android.newsbytes.DetailsActivity.java
/** * Creates the starting views required for the shared element transition. *//*from ww w . j av a 2 s .c om*/ private void createTransitionStartViews(Bundle bundle) { // Create the view objects. mThumbnailView = new ImageView(this); mHeadlineView = new TextView(this); // Set the thumbnail view parameters. mThumbnailView.setX(bundle.getFloat(MainActivity.IMAGE_XPOS)); mThumbnailView.setY(bundle.getFloat(MainActivity.IMAGE_YPOS)); byte[] thumbnailByteStream = bundle.getByteArray(MainActivity.IMAGE); if (thumbnailByteStream != null && thumbnailByteStream.length != 0) { // Get the thumbnail bitmap from byte array. Bitmap thumbnailBitmap = BitmapFactory.decodeByteArray(thumbnailByteStream, 0, thumbnailByteStream.length); // Set the thumbnail bitmap into the image view. if (thumbnailBitmap != null) { mThumbnailView.setImageBitmap(thumbnailBitmap); mThumbnailView.setScaleType(ImageView.ScaleType.FIT_XY); } } // Set the thumbnail view parameters. mHeadlineView.setX(bundle.getFloat(MainActivity.TEXT_XPOS)); mHeadlineView.setY(bundle.getFloat(MainActivity.TEXT_YPOS)); mHeadlineView.setText(bundle.getString(MainActivity.TEXT)); }