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.plugin.gallery.ForegroundGalleryLauncher.java
/** * Called when the camera view exits./*from w ww.j a v a2s .co m*/ * * @param requestCode * The request code originally supplied to * startActivityForResult(), allowing you to identify who this * result came from. * @param resultCode * The integer result code returned by the child activity through * its setResult(). * @param intent * An Intent, which can return result data to the caller (various * data can be attached to Intent "extras"). */ @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { Uri uri = intent.getData(); String fileURL = intent.getStringExtra("fileURL"); System.out.println("fileURL = " + fileURL); ContentResolver resolver = this.cordova.getActivity().getContentResolver(); try { Bitmap bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri)); bitmap = scaleBitmap(bitmap); this.processPicture(bitmap); bitmap.recycle(); bitmap = null; this.callbackContext.success("" + fileURL); System.gc(); } catch (FileNotFoundException e) { e.printStackTrace(); this.failPicture("Error retrieving image."); } } else if (resultCode == Activity.RESULT_CANCELED) { this.failPicture("Selection cancelled."); } else { this.failPicture("Selection did not complete!"); } }
From source file:at.bitfire.davdroid.ui.setup.AccountDetailsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View v = inflater.inflate(R.layout.login_account_details, container, false); Button btnBack = (Button) v.findViewById(R.id.back); btnBack.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a 2 s .c o m public void onClick(View v) { getFragmentManager().popBackStack(); } }); DavResourceFinder.Configuration config = (DavResourceFinder.Configuration) getArguments() .getSerializable(KEY_CONFIG); final EditText editName = (EditText) v.findViewById(R.id.account_name); editName.setText( (config.calDAV != null && config.calDAV.email != null) ? config.calDAV.email : config.userName); // CardDAV-specific v.findViewById(R.id.carddav).setVisibility(config.cardDAV != null ? View.VISIBLE : View.GONE); spnrGroupMethod = (Spinner) v.findViewById(R.id.contact_group_method); Button btnCreate = (Button) v.findViewById(R.id.create_account); btnCreate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String name = editName.getText().toString(); if (name.isEmpty()) editName.setError(getString(R.string.login_account_name_required)); else { if (createAccount(name, (DavResourceFinder.Configuration) getArguments().getSerializable(KEY_CONFIG))) { getActivity().setResult(Activity.RESULT_OK); getActivity().finish(); } else Snackbar.make(v, R.string.login_account_not_created, Snackbar.LENGTH_LONG).show(); } } }); return v; }
From source file:com.chess.genesis.activity.LoginFrag.java
private void handleNetwork(final Message msg) { final JSONObject json = (JSONObject) msg.obj; try {//from ww w . j a v a 2s . co m if (json.getString("result").equals("error")) { exitActivity = false; progress.remove(); Toast.makeText(act, "ERROR:\n" + json.getString("reason"), Toast.LENGTH_LONG).show(); return; } } catch (final JSONException e) { throw new RuntimeException(e.getMessage(), e); } switch (msg.what) { case NetworkClient.LOGIN: progress.setText("Syncing Data"); EditText txt = (EditText) act.findViewById(R.id.username); final String username = txt.getText().toString().trim(); txt = (EditText) act.findViewById(R.id.password); final String password = txt.getText().toString(); final PrefEdit pref = new PrefEdit(act); pref.putBool(R.array.pf_isLoggedIn, true); pref.putString(R.array.pf_username, username); pref.putString(R.array.pf_passhash, password); pref.commit(); SocketClient.getInstance().setIsLoggedIn(true); final SyncClient sync = new SyncClient(act, handle); sync.setSyncType(SyncClient.FULL_SYNC); new Thread(sync).start(); break; case SyncClient.MSG: // start background notifier act.startService(new Intent(act, GenesisNotifier.class)); final GameDataDB db = new GameDataDB(act); db.recalcYourTurn(); db.close(); sendResult(Activity.RESULT_OK); progress.dismiss(); break; } }
From source file:com.meetingninja.csse.user.ProfileFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { if (requestCode == 7) { displayedUser = ((UserParcel) data.getParcelableExtra(Keys.User.PARCEL)).getUser(); setUser(displayedUser);/*from ww w . ja v a 2 s .c om*/ } } }
From source file:most.voip.example.remote_config.LoginActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // Check which request we're responding to if (requestCode == REMOTE_ACCOUNT_CONFIG_REQUEST) { // Make sure the request was successful if (resultCode == RESULT_OK) { Intent resultIntent = new Intent(); Bundle b = new Bundle(); b.putString("account_data", data.getExtras().getString("account_data")); b.putString("buddies_data", data.getExtras().getString("buddies_data")); resultIntent.putExtras(b);/*from w w w . ja v a2 s.c o m*/ // TODO Add extras or a data URI to this intent as appropriate. Log.d("VoipConfigDemo", "Configuration accepted"); setResult(Activity.RESULT_OK, resultIntent); finish(); } else { Log.d("VoipConfigDemo", "Account data NOT received from the activity"); } } else { Log.d("VoipConfigDemo", "Received unknown requestCode:" + String.valueOf(requestCode)); } }
From source file:co.uk.gauntface.cordova.plugin.nativegplussignin.CordovaGPlusOauthPlugin.java
@Override public void onActivityResult(int requestCode, int responseCode, Intent intent) { Log.v(C.TAG, "onActivityResult()"); if (requestCode == REQUEST_CODE_RESOLVE_ERR && responseCode == Activity.RESULT_OK) { mConnectionResult = null;// w w w.j a v a2 s.c om Log.v(C.TAG, "onActivityResult() - getPlusClient().connect()"); getPlusClient().connect(); } else { super.onActivityResult(requestCode, responseCode, intent); } }
From source file:com.intel.xdk.contacts.Contacts.java
@SuppressWarnings("deprecation") public void contactsAdderActivityResult(int requestCode, int resultCode, Intent intent) { //Contact Added if (resultCode == Activity.RESULT_OK) { Cursor cursor = activity.managedQuery(intent.getData(), null, null, null, null); cursor.moveToNext();//from w w w .java 2 s. c om String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY)); getAllContacts(); String js = String.format( "var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.add',true,true);e.success=true;e.contactid='%s';document.dispatchEvent(e);", contactId); injectJS("javascript:" + js); busy = false; } //Contact not Added else { String js = "javascript: var e = document.createEvent('Events');e.initEvent('intel.xdk.contacts.add',true,true);e.success=false;e.cancelled=true;document.dispatchEvent(e);"; injectJS(js); busy = false; } }
From source file:cn.tycoon.lighttrans.fileManager.AbstractFilePickerActivity.java
@Override public void onFilePicked(final Uri file) { Intent i = new Intent(); i.setData(file); setResult(Activity.RESULT_OK, i); finish(); }
From source file:io.v.android.apps.syncslides.DeckChooserFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case REQUEST_CODE_IMPORT_DECK: if (resultCode != Activity.RESULT_OK) { String errorStr = data != null && data.hasExtra(DocumentsContract.EXTRA_ERROR) ? data.getStringExtra(DocumentsContract.EXTRA_ERROR) : ""; toast("Error selecting deck to import " + errorStr); break; }//from w ww.j a v a2 s. c o m Uri uri = data.getData(); importDeck(DocumentFile.fromTreeUri(getContext(), uri)); break; } }
From source file:com.arantius.tivocommander.ExploreCommon.java
protected void setRefreshResult() { Intent resultIntent = new Intent(); resultIntent.putExtra("refresh", true); getParent().setResult(Activity.RESULT_OK, resultIntent); }