List of usage examples for android.app Activity RESULT_OK
int RESULT_OK
To view the source code for android.app Activity RESULT_OK.
Click Source Link
From source file:com.barcamppenang2014.tabfragment.ProfileFragment.java
License:asdf
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Session.getActiveSession().onActivityResult(getActivity(), requestCode, resultCode, data); Log.d("yc", "call onActivityResult in profilefragment "); if (requestCode == GALLERY_REQUEST_CODE && resultCode == Activity.RESULT_OK) { // Recyle unused bitmaps /*/* www .jav a 2 s. co m*/ * if (bitmap != null) { bitmap.recycle(); } */ Uri uri = data.getData(); uriStr = uri.toString(); // save picUri to sharedpreference SharedPreferences sharedpreferences = getActivity().getSharedPreferences("MyPREFERENCES", Context.MODE_PRIVATE); Editor editor = sharedpreferences.edit(); // picUri could be 'none' or a valid picUri editor.putString("picuri", uriStr); editor.commit(); try { URIToBitmap(uri); } catch (Exception e) { e.printStackTrace(); } MainActivity._tempFragment = null; } }
From source file:com.flurry.samples.analytics.PhotoFeedActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case REQUEST_CHECK_SETTINGS: switch (resultCode) { case Activity.RESULT_OK: if (googleApiClient != null && !googleApiClient.isConnected()) { googleApiClient.connect(); }/*from w w w . j a v a2 s. com*/ startLocationUpdates(); break; case Activity.RESULT_CANCELED: Toast.makeText(getApplicationContext(), "Location services not enabled. To use this app, enable location services.", Toast.LENGTH_LONG).show(); finish(); break; default: break; } break; } }
From source file:com.megster.cordova.ble.central.BLECentralPlugin.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_ENABLE_BLUETOOTH) { if (resultCode == Activity.RESULT_OK) { LOG.d(TAG, "User enabled Bluetooth"); if (enableBluetoothCallback != null) { enableBluetoothCallback.success(); }// w w w . j ava 2 s. c om } else { LOG.d(TAG, "User did *NOT* enable Bluetooth"); if (enableBluetoothCallback != null) { enableBluetoothCallback.error("User did not enable Bluetooth"); } } enableBluetoothCallback = null; } }
From source file:com.ct.speech.HintReceiver.java
/** * Handle the results from the recognition activity. *///w ww . j av a2s .co m @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { // Fill the list view with the strings the recognizer thought it // could have heard ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); speechResults(requestCode, matches); } else if (resultCode == Activity.RESULT_CANCELED) { // cancelled by user speechFailure("Cancelled"); } else { speechFailure("Unknown error"); } super.onActivityResult(requestCode, resultCode, data); }
From source file:li.barter.fragments.LoginFragment.java
@Override public void onSuccess(final int requestId, final IBlRequestContract request, final ResponseInfo response) { if (requestId == RequestId.CREATE_USER) { final Bundle userInfo = response.responseBundle; Utils.updateUserInfoFromBundle(userInfo, true); BarterLiApplication.startChatService(); final String locationId = userInfo.getString(HttpConstants.LOCATION); Intent returnIntent = getDefaultOnwardIntent(); if (TextUtils.isEmpty(locationId)) { returnIntent = new Intent(getActivity(), SelectPreferredLocationActivity.class); returnIntent.putExtra(Keys.ONWARD_INTENT, getDefaultOnwardIntent()); }// ww w. j a v a2 s .c o m final Intent data = new Intent(); data.putExtra(Keys.ONWARD_INTENT, returnIntent); getActivity().setResult(Activity.RESULT_OK, returnIntent); getActivity().finish(); } else if (requestId == RequestId.REQUEST_RESET_TOKEN) { final Intent resetPasswordIntent = new Intent(getActivity(), PasswordResetActivity.class); resetPasswordIntent.putExtra(Keys.EMAIL, mEmailForPasswordChange); if (getArguments() != null) { resetPasswordIntent.putExtras(getArguments()); } startActivityForResult(resetPasswordIntent, AppConstants.RequestCodes.RESET_PASSWORD); } }
From source file:fm.smart.r1.ItemActivity.java
public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); // this should be called once image has been chosen by user // using requestCode to pass item id - haven't worked out any other way // to do it/* www . j av a2s.c om*/ // if (requestCode == SELECT_IMAGE) if (resultCode == Activity.RESULT_OK) { // TODO check if user is logged in if (LoginActivity.isNotLoggedIn(this)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setClassName(this, LoginActivity.class.getName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); // avoid navigation back to this? LoginActivity.return_to = ItemActivity.class.getName(); LoginActivity.params = new HashMap<String, String>(); LoginActivity.params.put("item_id", (String) item.getId()); startActivity(intent); // TODO in this case forcing the user to rechoose the image // seems a little // rude - should probably auto-submit here ... } else { // Bundle extras = data.getExtras(); // String sentence_id = (String) extras.get("sentence_id"); final ProgressDialog myOtherProgressDialog = new ProgressDialog(this); myOtherProgressDialog.setTitle("Please Wait ..."); myOtherProgressDialog.setMessage("Uploading image ..."); myOtherProgressDialog.setIndeterminate(true); myOtherProgressDialog.setCancelable(true); final Thread add_image = new Thread() { public void run() { // TODO needs to check for interruptibility String sentence_id = Integer.toString(requestCode); Uri selectedImage = data.getData(); // Bitmap bitmap = Media.getBitmap(getContentResolver(), // selectedImage); // ByteArrayOutputStream bytes = new // ByteArrayOutputStream(); // bitmap.compress(Bitmap.CompressFormat.JPEG, 40, // bytes); // ByteArrayInputStream fileInputStream = new // ByteArrayInputStream( // bytes.toByteArray()); // TODO Might have to save to file system first to get // this // to work, // argh! // could think of it as saving to cache ... // add image to sentence FileInputStream is = null; FileOutputStream os = null; File file = null; ContentResolver resolver = getContentResolver(); try { Bitmap bitmap = Media.getBitmap(getContentResolver(), selectedImage); ByteArrayOutputStream bytes = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.JPEG, 40, bytes); // ByteArrayInputStream bais = new // ByteArrayInputStream(bytes.toByteArray()); // FileDescriptor fd = // resolver.openFileDescriptor(selectedImage, // "r").getFileDescriptor(); // is = new FileInputStream(fd); String filename = "test.jpg"; File dir = ItemActivity.this.getDir("images", MODE_WORLD_READABLE); file = new File(dir, filename); os = new FileOutputStream(file); // while (bais.available() > 0) { // / os.write(bais.read()); // } os.write(bytes.toByteArray()); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { if (os != null) { try { os.close(); } catch (IOException e) { } } if (is != null) { try { is.close(); } catch (IOException e) { } } } // File file = new // File(Uri.decode(selectedImage.toString())); // ensure item is in users default list ItemActivity.add_item_result = new AddItemResult(Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id, item.getId(), null)); Result result = ItemActivity.add_item_result; if (ItemActivity.add_item_result.success() || ItemActivity.add_item_result.alreadyInList()) { // ensure sentence is in users default goal ItemActivity.add_sentence_goal_result = new AddSentenceResult( Main.lookup.addSentenceToGoal(Main.transport, Main.default_study_goal_id, item.getId(), sentence_id, null)); result = ItemActivity.add_sentence_goal_result; if (ItemActivity.add_sentence_goal_result.success()) { String media_entity = "http://test.com/test.jpg"; String author = "tansaku"; String author_url = "http://smart.fm/users/tansaku"; Log.d("DEBUG-IMAGE-URI", selectedImage.toString()); ItemActivity.add_image_result = addImage(file, media_entity, author, author_url, "1", sentence_id, (String) item.getId(), Main.default_study_goal_id); result = ItemActivity.add_image_result; } } final Result display = result; myOtherProgressDialog.dismiss(); ItemActivity.this.runOnUiThread(new Thread() { public void run() { final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create(); dialog.setTitle(display.getTitle()); dialog.setMessage(display.getMessage()); dialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (ItemActivity.add_image_result != null && ItemActivity.add_image_result.success()) { ItemListActivity.loadItem(ItemActivity.this, item.getId().toString()); } } }); dialog.show(); } }); } }; myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { add_image.interrupt(); } }); OnCancelListener ocl = new OnCancelListener() { public void onCancel(DialogInterface arg0) { add_image.interrupt(); } }; myOtherProgressDialog.setOnCancelListener(ocl); closeMenu(); myOtherProgressDialog.show(); add_image.start(); } } }
From source file:com.yschi.castscreen.MainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_MEDIA_PROJECTION) { if (resultCode != Activity.RESULT_OK) { Log.d(TAG, "User cancelled"); Toast.makeText(mContext, R.string.user_cancelled, Toast.LENGTH_SHORT).show(); return; }/*from w w w . ja v a2s . c o m*/ Log.d(TAG, "Starting screen capture"); mResultCode = resultCode; mResultData = data; startCaptureScreen(); } }
From source file:com.ntsync.android.sync.activities.ShopActivity.java
@Override protected void onResumeFragments() { super.onResumeFragments(); // Process a PaymentResult from onActivityResult if (paymentResult != null) { int resultCode = paymentResult.resultCode; PaymentConfirmation confirm = paymentResult.confirmation; paymentResult = null;//from www .ja va2s .c om if (resultCode == Activity.RESULT_OK && confirm != null) { if (selectedPriceId == null) { MessageDialog.show(R.string.shop_activity_missingprice, this); return; } JSONObject paymentJson = confirm.toJSONObject(); // Save Payment, so that payment can be verified later. Account account = new Account(accountName, Constants.ACCOUNT_TYPE); AccountManager accountManager = AccountManager.get(this); SyncUtils.savePayment(account, accountManager, paymentJson, selectedPriceId); SyncUtils.startPaymentVerification(); // Start Timer to verify Payment if Verification could not be // done now. PaymentVerificationService.startVerificationTimer(getApplicationContext()); // Send Confirmation to server boolean verifStarted = false; try { String jsonData = paymentJson.toString(1); VerifyPaymentProgressDialog progressDialog = VerifyPaymentProgressDialog .newInstance(selectedPriceId, jsonData, accountName); progressDialog.show(this.getSupportFragmentManager(), "VerifyPaymentProgressDialog"); if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "PaymentConfirmation: " + jsonData); } verifStarted = true; } catch (JSONException e) { MessageDialog.show(R.string.shop_activity_invalidsyntax, this); Log.e(TAG, "Failed to convert Payment to JSON.", e); SyncUtils.savePayment(account, accountManager, null, null); } finally { if (!verifStarted) { SyncUtils.stopPaymentVerification(); } } } else if (resultCode == Activity.RESULT_CANCELED) { Log.i(TAG, "The user canceled the payment-flow"); } else if (resultCode == PaymentActivity.RESULT_PAYMENT_INVALID) { MessageDialog.show(R.string.shop_activity_invalidpayment, this); Log.i(TAG, "An invalid payment was submitted."); } else { MessageDialog.show(R.string.shop_activity_invalidpayment, this); Log.e(TAG, "PaymentResult is unknown. Result:" + resultCode + " Confirmation:" + confirm); } } getSupportLoaderManager().initLoader(LOADID_PRICES, null, this); View progressBar = findViewById(R.id.progressBar); View reloadBtn = findViewById(R.id.reloadBtn); reloadBtn.setVisibility(View.GONE); progressBar.setVisibility(View.VISIBLE); getListView().setEmptyView(progressBar); // Show a Message from a delayed Verification String msg = getIntent().getStringExtra(PARM_MSG); if (msg != null) { MessageDialog.show(msg, this); getIntent().removeExtra(PARM_MSG); } }
From source file:com.example.mynsocial.BluetoothChat.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.e(TAG, "+++ onActivityResult +++"); if (D)//from w w w . jav a 2 s.co m Log.d(TAG, "onActivityResult " + resultCode); switch (requestCode) { case REQUEST_CONNECT_DEVICE_SECURE: // When DeviceListActivity returns with a device to connect if (resultCode == Activity.RESULT_OK) { connectDevice(data, true); } break; case REQUEST_ENABLE_BT: // When the request to enable Bluetooth returns if (resultCode == Activity.RESULT_OK) { // Bluetooth is now enabled, so set up a chat session setupChat(); } else { // User did not enable Bluetooth or an error occurred Log.d(TAG, "BT not enabled"); finish(); } } }
From source file:com.funambol.android.controller.AndroidRegisterScreenController.java
/** * Progress Dialog//from w ww. j ava2s . c om * TODO: */ public void syncEnded() { Log.debug(TAG_LOG, "Sync Ended"); //super.syncEnded(); userAuthenticated(); // Intent resultIntent = new Intent(); resultIntent.putExtra("user", screen.getUsername()); resultIntent.putExtra("password", screen.getPassword()); screen.setResult(Activity.RESULT_OK, resultIntent); screen.finish(); }