List of usage examples for android.os Bundle putByteArray
@Override public void putByteArray(@Nullable String key, @Nullable byte[] value)
From source file:com.example.suspectedBug.myapplication.IapSampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle developerInfo = new Bundle(); developerInfo.putString(OuyaFacade.OUYA_DEVELOPER_ID, DEVELOPER_ID); developerInfo.putByteArray(OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, APPLICATION_KEY); ouyaFacade = OuyaFacade.getInstance(); ouyaFacade.init(this, developerInfo); // Uncomment this line to test against the server using "fake" credits. // This will also switch over to a separate "test" purchase history. //ouyaFacade.setTestMode(); setContentView(R.layout.sample_app); receiptListView = (ListView) findViewById(R.id.receipts); receiptListView.setFocusable(false); /*//from w ww.j a v a 2 s.co m * In order to avoid "application not responding" popups, Android demands that long-running operations * happen on a background thread. Listener objects provide a way for you to specify what ought to happen * at the end of the long-running operation. Examples of this pattern in Android include * android.os.AsyncTask. */ /*findViewById(R.id.gamer_uuid_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fetchGamerInfo(); } });*/ findViewById(R.id.openOtherActivity).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent openOtherActivityIntent = new Intent(IapSampleActivity.this, MainActivity.class); startActivity(openOtherActivityIntent); } }); // Attempt to restore the product and receipt list from the savedInstanceState Bundle if (savedInstanceState != null) { if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) { Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY); mProductList = new ArrayList<Product>(products.length); for (Parcelable product : products) { mProductList.add((Product) product); } addProducts(); } if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) { Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY); mReceiptList = new ArrayList<Receipt>(receipts.length); for (Parcelable receipt : receipts) { mReceiptList.add((Receipt) receipt); } addReceipts(); } } // Request the product list if it could not be restored from the savedInstanceState Bundle if (mProductList == null) { requestProducts(); } // Make sure the receipt ListView starts empty if the receipt list could not be restored // from the savedInstanceState Bundle. if (mReceiptList == null) { receiptListView.setAdapter(new ReceiptAdapter(this, new Receipt[0])); } }
From source file:com.cnm.cnmrc.fragment.search.SearchVodSub.java
private Bundle makeBundle(View view, int position) { String title = adapter.getItem(position).getTitle(); String hd = adapter.getItem(position).getHd(); String grade = adapter.getItem(position).getGrade(); String director = adapter.getItem(position).getDirector(); String actor = adapter.getItem(position).getActor(); String price = adapter.getItem(position).getPrice(); String contents = adapter.getItem(position).getContents(); ImageView logo = (ImageView) view.findViewById(R.id.logo_img); Bitmap logoImage = ((BitmapDrawable) logo.getDrawable()).getBitmap(); // ? no image ? ?? . Bundle bundle = new Bundle(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); Bitmap bitmap = logoImage;/*from ww w . j ava 2s .c om*/ boolean result = bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); if (result) { // ?? ... not all Formats support all bitmap configs directly } else { bitmap = Util.getNoBitmap(getActivity()); bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); } byte[] logoImg = baos.toByteArray(); bundle.putByteArray("logoImg", logoImg); bundle.putString("title", title); bundle.putString("hd", hd); bundle.putString("grade", grade); bundle.putString("director", director); bundle.putString("actor", actor); bundle.putString("price", price); bundle.putString("contents", contents); return bundle; }
From source file:org.sufficientlysecure.keychain.ui.ImportKeysActivity.java
/** * Import keys with mImportData/*w w w.j av a 2 s.co m*/ */ public void importKeys() { if (mImportData != null || mImportFilename != null) { Log.d(Constants.TAG, "importKeys started"); // Send all information needed to service to import key in other thread Intent intent = new Intent(this, KeychainIntentService.class); intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_IMPORT_KEYRING); // fill values for this action Bundle data = new Bundle(); // TODO: check for key type? // data.putInt(ApgIntentService.IMPORT_KEY_TYPE, Id.type.secret_key); if (mImportData != null) { data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); data.putByteArray(KeychainIntentService.IMPORT_BYTES, mImportData); } else { data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_FILE); data.putString(KeychainIntentService.IMPORT_FILENAME, mImportFilename); } intent.putExtra(KeychainIntentService.EXTRA_DATA, data); // Message is received after importing is done in ApgService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { // handle messages by standard ApgHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { // get returned data bundle Bundle returnData = message.getData(); int added = returnData.getInt(KeychainIntentService.RESULT_IMPORT_ADDED); int updated = returnData.getInt(KeychainIntentService.RESULT_IMPORT_UPDATED); int bad = returnData.getInt(KeychainIntentService.RESULT_IMPORT_BAD); String toastMessage; if (added > 0 && updated > 0) { toastMessage = getString(R.string.keysAddedAndUpdated, added, updated); } else if (added > 0) { toastMessage = getString(R.string.keysAdded, added); } else if (updated > 0) { toastMessage = getString(R.string.keysUpdated, updated); } else { toastMessage = getString(R.string.noKeysAddedOrUpdated); } Toast.makeText(ImportKeysActivity.this, toastMessage, Toast.LENGTH_SHORT).show(); if (bad > 0) { AlertDialog.Builder alert = new AlertDialog.Builder(ImportKeysActivity.this); alert.setIcon(android.R.drawable.ic_dialog_alert); alert.setTitle(R.string.warning); alert.setMessage(ImportKeysActivity.this.getString(R.string.badKeysEncountered, bad)); alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alert.setCancelable(true); alert.create().show(); } else if (mDeleteAfterImport) { // everything went well, so now delete, if that was turned on DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment .newInstance(mImportFilename); deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); } } }; }; // Create a new Messenger for the communication back Messenger messenger = new Messenger(saveHandler); intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); // show progress dialog saveHandler.showProgressDialog(this); // start service with intent startService(intent); } else { Toast.makeText(this, R.string.error_nothingImport, Toast.LENGTH_LONG).show(); } }
From source file:com.guillaumesoft.escapehellprison.PurchaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mOuyaFacade = OuyaFacade.getInstance(); Bundle developerInfo = new Bundle(); developerInfo.putString(OuyaFacade.OUYA_DEVELOPER_ID, DEVELOPER_ID); developerInfo.putByteArray(OuyaFacade.OUYA_DEVELOPER_PUBLIC_KEY, loadApplicationKey()); mOuyaFacade = OuyaFacade.getInstance(); mOuyaFacade.init(this, developerInfo); // Uncomment this line to test against the server using "fake" credits. // This will also switch over to a separate "test" purchase history. //ouyaFacade.setTestMode(); setContentView(R.layout.sample_app); receiptListView = (ListView) findViewById(R.id.receipts); receiptListView.setFocusable(false); /*/*from w ww . ja v a 2 s.c om*/ * In order to avoid "application not responding" popups, Android demands that long-running operations * happen on a background thread. Listener objects provide a way for you to specify what ought to happen * at the end of the long-running operation. Examples of this pattern in Android include * android.os.AsyncTask. */ findViewById(R.id.gamer_uuid_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { fetchGamerInfo(); } }); // Attempt to restore the product and receipt list from the savedInstanceState Bundle if (savedInstanceState != null) { if (savedInstanceState.containsKey(PRODUCTS_INSTANCE_STATE_KEY)) { Parcelable[] products = savedInstanceState.getParcelableArray(PRODUCTS_INSTANCE_STATE_KEY); mProductList = new ArrayList<Product>(products.length); for (Parcelable product : products) { mProductList.add((Product) product); } addProducts(); } if (savedInstanceState.containsKey(RECEIPTS_INSTANCE_STATE_KEY)) { Parcelable[] receipts = savedInstanceState.getParcelableArray(RECEIPTS_INSTANCE_STATE_KEY); mReceiptList = new ArrayList<Receipt>(receipts.length); for (Parcelable receipt : receipts) { mReceiptList.add((Receipt) receipt); } addReceipts(); } } // Request the product list if it could not be restored from the savedInstanceState Bundle if (mProductList == null) { requestProducts(); } // Make sure the receipt ListView starts empty if the receipt list could not be restored // from the savedInstanceState Bundle. if (mReceiptList == null) { receiptListView.setAdapter(new ReceiptAdapter(this, new Receipt[0])); } // Create a PublicKey object from the key data downloaded from the developer portal. try { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(loadApplicationKey()); KeyFactory keyFactory = KeyFactory.getInstance("RSA"); mPublicKey = keyFactory.generatePublic(keySpec); } catch (Exception e) { Log.e(LOG_TAG, "Unable to create encryption key", e); } }
From source file:edu.cloud.iot.reception.ocr.ScanLicense.java
public void nextHandler(View view) { boolean processedImage = false; // call AsynTask to perform network operation on separate thread try {//from www. j a v a2s . co m asyncOCR = new AsyncOCR(); asyncOCR.setParent(this); // asyncOCR = new AsyncOCR(); // asyncOCR.setParent(this); // asyncFaceRecog.setBaseFile(imageBytes); // asyncFaceRecog.setCompareFile(imageBytes); Log.i("EDebug::ResponseOutput", "Triggering OCR service.."); // Log.i("ImageByteArray", "Image --> "+imageBytes.length); asyncOCR.setScanImage(imageBytes); Toast.makeText(getBaseContext(), "Processing image..", Toast.LENGTH_LONG).show(); asyncOCR.execute(""); while (!asyncOCR.processCompleted()) { Log.i("EDebug::OCRProcessStatus: ", "Waiting for Async"); Toast.makeText(getBaseContext(), "Processing image..", Toast.LENGTH_LONG).show(); Thread.sleep(2000);// Toast.LENGTH_LONG) ; } processedImage = true; // jsonResponse = asyncFaceRecog.getResponse(); // Log.i("ResponseOutput", jsonResponse.toString(1)); } catch (Exception ex) { Log.i("EDebug::OCRError", "ERROR" + ex.getLocalizedMessage()); ex.printStackTrace(); } Log.i("EDebug::nextHander processImage = ", "" + processedImage); asyncOCR.itOCR.imageProcessed = true; if (asyncOCR.itOCR.imageProcessed) { String status = "completed"; // Log.i("EDebug::nextHander status = ", // ""+asyncOCR.itOCR.task1.Status); if (status.equalsIgnoreCase("completed")) { try { Intent faceRecogIntent = new Intent(this, CaptureImageInstructionActivity.class); // faceRecogIntent.putExtra("Check1","Data1"); Bundle fwdMsg = new Bundle(); // ArrayList<String> al = (new ArrayList<String>()); // al.add("Data2"); // fwdMsg.putSerializable("al", al); fwdMsg.putSerializable("ocrresponse", asyncOCR.getOcrResponse()); // Log.i("EDebug::ocrresponse = ",asyncOCR.getOcrResponse().toString()); fwdMsg.putByteArray("licensebytes", imageBytes); fwdMsg.putString("licenseImgPath", licenseImgPath); faceRecogIntent.putExtra("list", fwdMsg); // Log.i("EDebug::","Starting FaceRecog Activity"); if (cameraView.camera != null) { cameraView.camera.stopPreview(); cameraView.camera.release(); cameraView.camera = null; cameraView = null; } Log.i("Scan Activity:: OcrData::", asyncOCR.getOcrResponse().toString() + ""); startActivity(faceRecogIntent); Log.i("EDebug::", "Started FaceRecog Activity"); } catch (Exception ex) { Log.i("EDebug::ScanLicense nextClik: ", "Error: " + ex.getLocalizedMessage() + "::" + ex.getMessage()); } } else { Toast.makeText(this, "Error occured! Please process the image again.", Toast.LENGTH_LONG).show(); } } else { Toast.makeText(this, "Error occured! Please process the image again.", Toast.LENGTH_LONG).show(); } }
From source file:com.lib.DstabiProvider.java
private void sendHandleNotStop(int callBackCode, byte[] data) { Bundle budleForMsg = new Bundle(); budleForMsg.putByteArray("data", data); Message m = connectionHandler.obtainMessage(callBackCode); m.setData(budleForMsg);/*from w ww.jav a 2 s . c o m*/ connectionHandler.sendMessage(m); //Log.d(TAG, "zprava poslana not stop: " + callBackCode); }
From source file:com.lib.DstabiProvider.java
private void sendHandle(int callBackCode, byte[] data) { Bundle budleForMsg = new Bundle(); budleForMsg.putByteArray("data", data); Message m = connectionHandler.obtainMessage(callBackCode); m.setData(budleForMsg);/* w w w. j a v a2s. c o m*/ connectionHandler.sendMessage(m); Log.d(TAG, "zprava poslana"); clearState("send handle"); }
From source file:com.wareninja.opensource.common.wsrequest.WebServiceNew.java
public String webPost(String methodName, Bundle params) throws MalformedURLException, IOException { // random string as boundary for multi-part http post String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f"; String endLine = "\r\n"; OutputStream os;/* www . ja va2 s . c om*/ ret = null; String postUrl = webServiceUrl + methodName; if (LOGGING.DEBUG) { Log.d(TAG, "POST URL: " + postUrl); } HttpURLConnection conn = (HttpURLConnection) new URL(postUrl).openConnection(); conn.setRequestProperty("User-Agent", System.getProperties().getProperty("http.agent") + " WareNinjaAndroidSDK"); HttpParams httpParams = httpClient.getParams(); HttpProtocolParams.setUseExpectContinue(httpParams, false); Bundle dataparams = new Bundle(); for (String key : params.keySet()) { byte[] byteArr = null; try { byteArr = (byte[]) params.get(key); } catch (Exception ex1) { } if (byteArr != null) dataparams.putByteArray(key, byteArr); } conn.setRequestMethod("POST"); conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary); conn.setDoOutput(true); conn.setDoInput(true); conn.setRequestProperty("Connection", "Keep-Alive"); appendRequestHeaders(conn, headers); conn.connect(); os = new BufferedOutputStream(conn.getOutputStream()); os.write(("--" + strBoundary + endLine).getBytes()); os.write((WareNinjaUtils.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 = WareNinjaUtils.read(conn.getInputStream()); } catch (FileNotFoundException e) { // Error Stream contains JSON that we can parse to a FB error response = WareNinjaUtils.read(conn.getErrorStream()); } if (LOGGING.DEBUG) Log.d(TAG, "POST response: " + response); return response; }
From source file:de.earthlingz.oerszebra.DroidZebra.java
@Override protected void onSaveInstanceState(Bundle outState) { ZebraBoard gs = mZebraThread.getGameState(); if (gs != null) { outState.putByteArray("moves_played", gs.getMoveSequence()); outState.putInt("moves_played_count", gs.getDisksPlayed()); outState.putInt("version", 1); }//from w w w. j a v a 2 s .co m }