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:org.klnusbaum.udj.EventListFragment.java
public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case ACCOUNT_CREATION: if (resultCode == Activity.RESULT_OK) { account = (Account) data.getParcelableExtra(Constants.ACCOUNT_EXTRA); } else {//from w ww . j ava 2 s.c o m getActivity().setResult(Activity.RESULT_CANCELED); getActivity().finish(); } break; } }
From source file:aenadon.wienerlinienalarm.activities.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { tabAdapter.notifyDataSetChanged(); if (data != null) { AlarmType alarmType = (AlarmType) data.getSerializableExtra(Keys.Extra.ALARM_TYPE); tabContainer.setCurrentItem(alarmType.ordinal()); }/*from w w w. j a va 2 s.c om*/ } if (data != null) { String snackbarMessage = data.getStringExtra(Keys.Extra.SNACKBAR_MESSAGE); if (snackbarMessage != null) { Snackbar.make(findViewById(R.id.fab_main), snackbarMessage, Snackbar.LENGTH_LONG).show(); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:com.phonegap.plugins.speech.XSpeechRecognizer.java
private void getSupportedLanguages() { if (languageDetailsChecker == null) { languageDetailsChecker = new LanguageDetailsChecker(callbackContext); }/*from w ww. j ava 2 s. c om*/ Intent detailsIntent = new Intent(RecognizerIntent.ACTION_GET_LANGUAGE_DETAILS); cordova.getActivity().sendOrderedBroadcast(detailsIntent, null, languageDetailsChecker, null, Activity.RESULT_OK, null, null); }
From source file:com.remobile.contacts.ContactManager.java
/** * Called when user picks contact.//w w w . j a v a 2s .com * @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"). * @throws JSONException */ public void onActivityResult(int requestCode, int resultCode, final Intent intent) { if (requestCode == cordova.CONTACT_PICKER_RESULT) { if (resultCode == Activity.RESULT_OK) { String contactId = intent.getData().getLastPathSegment(); // to populate contact data we require Raw Contact ID // so we do look up for contact raw id first Cursor c = this.cordova.getActivity().getContentResolver().query(RawContacts.CONTENT_URI, new String[] { RawContacts._ID }, RawContacts.CONTACT_ID + " = " + contactId, null, null); if (!c.moveToFirst()) { this.callbackContext.error("Error occured while retrieving contact raw id"); return; } String id = c.getString(c.getColumnIndex(RawContacts._ID)); c.close(); try { JSONObject contact = contactAccessor.getContactById(id); this.callbackContext.success(contact); return; } catch (JSONException e) { Log.e(LOG_TAG, "JSON fail.", e); } } else if (resultCode == Activity.RESULT_CANCELED) { this.callbackContext .sendPluginResult(new PluginResult(PluginResult.Status.NO_RESULT, UNKNOWN_ERROR)); return; } this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, UNKNOWN_ERROR)); } }
From source file:circleplus.app.MainActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == Activity.RESULT_OK) { selectItem(requestCode);/*from w ww. j a v a 2s . c o m*/ } }
From source file:org.andrico.andrico.facebook.FBBase.java
/** * When a LoginActivity activity returns a LOGIN_REQUEST, parse its * response./*from w w w . j a v a2 s . c om*/ * * @param resultCode * @param data */ public Boolean handleLoginActivityResult(Context context, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { setSession(data.getStringExtra(LoginActivity.SESSION_KEY_EXTRA), data.getStringExtra(LoginActivity.SECRET_EXTRA), data.getStringExtra(LoginActivity.UID_EXTRA)); return true; } else { return false; } }
From source file:co.zzyzx.showtimes.android.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == REQUEST_LINK_TO_DBX) { if (resultCode == Activity.RESULT_OK) { DbxAccount account = mAccountManager.getLinkedAccount(); try { // Migrate any local datastores. app.datastoreManager.migrateToAccount(account); // Start using the remote app.datastore manager. app.datastoreManager = DbxDatastoreManager.forAccount(account); } catch (DbxException e) { e.printStackTrace();//from w ww .j a v a 2 s.c om } catch (DbxRuntimeException runtimeE) { runtimeE.printStackTrace(); } updateFavList(); } } else { super.onActivityResult(requestCode, resultCode, data); } }
From source file:cn.edu.nuc.seeworld.fg.ColorFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CAMERA && resultCode == Activity.RESULT_OK && null != data) { String sdState = Environment.getExternalStorageState(); if (!sdState.equals(Environment.MEDIA_MOUNTED)) { return; }/* www.j a v a2 s . com*/ String name = DateFormat.format("yyyyMMdd_hhmmss", Calendar.getInstance(Locale.CHINA)) + ".jpg"; Bundle bundle = data.getExtras(); //???? Bitmap bitmap = (Bitmap) bundle.get("data"); FileOutputStream fout = null; File file = new File("/sdcard/pintu/"); file.mkdirs(); String filename = file.getPath() + name; try { fout = new FileOutputStream(filename); pic_path = filename; bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { try { fout.flush(); fout.close(); } catch (IOException e) { e.printStackTrace(); } } pic_imageView.setImageBitmap(bitmap); pic_imageView.setVisibility(View.VISIBLE); } if (requestCode == PHOTO && resultCode == Activity.RESULT_OK && null != data) { Uri selectedImage = data.getData(); String[] filePathColumns = { MediaStore.Images.Media.DATA }; Cursor c = this.getActivity().getContentResolver().query(selectedImage, filePathColumns, null, null, null); c.moveToFirst(); int columnIndex = c.getColumnIndex(filePathColumns[0]); String picturePath = c.getString(columnIndex); c.close(); //? Log.d("SEEWORLDTAG", picturePath); Bitmap bitmap = BitmapFactory.decodeFile(picturePath); pic_path = picturePath; pic_imageView.setImageBitmap(bitmap); pic_imageView.setVisibility(View.VISIBLE); } }
From source file:com.bellman.bible.android.view.activity.search.Search.java
/** * I don't think this is used because of hte finish() in onSearch() * TODO remove//from w ww .ja v a 2 s. c o m */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { returnToPreviousScreen(); } }
From source file:com.sip.pwc.sipphone.service.Downloader.java
@Override protected void onHandleIntent(Intent intent) { HttpGet getMethod = new HttpGet(intent.getData().toString()); int result = Activity.RESULT_CANCELED; String outPath = intent.getStringExtra(EXTRA_OUTPATH); boolean checkMd5 = intent.getBooleanExtra(EXTRA_CHECK_MD5, false); int icon = intent.getIntExtra(EXTRA_ICON, 0); String title = intent.getStringExtra(EXTRA_TITLE); boolean showNotif = (icon > 0 && !TextUtils.isEmpty(title)); // Build notification Builder nb = new Builder(this); nb.setWhen(System.currentTimeMillis()); nb.setContentTitle(title);/*from w w w .j av a 2 s . c o m*/ nb.setSmallIcon(android.R.drawable.stat_sys_download); nb.setOngoing(true); Intent i = new Intent(this, SipHome.class); nb.setContentIntent(PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT)); RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.download_notif); contentView.setImageViewResource(R.id.status_icon, icon); contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.downloading_text)); contentView.setProgressBar(R.id.status_progress, 50, 0, false); contentView.setViewVisibility(R.id.status_progress_wrapper, View.VISIBLE); nb.setContent(contentView); final Notification notification = showNotif ? nb.build() : null; notification.contentView = contentView; if (!TextUtils.isEmpty(outPath)) { try { File output = new File(outPath); if (output.exists()) { output.delete(); } if (notification != null) { notificationManager.notify(NOTIF_DOWNLOAD, notification); } ResponseHandler<Boolean> responseHandler = new FileStreamResponseHandler(output, new Progress() { private int oldState = 0; @Override public void run(long progress, long total) { //Log.d(THIS_FILE, "Progress is "+progress+" on "+total); int newState = (int) Math.round(progress * 50.0f / total); if (oldState != newState) { notification.contentView.setProgressBar(R.id.status_progress, 50, newState, false); notificationManager.notify(NOTIF_DOWNLOAD, notification); oldState = newState; } } }); boolean hasReply = client.execute(getMethod, responseHandler); if (hasReply) { if (checkMd5) { URL url = new URL(intent.getData().toString().concat(".md5sum")); InputStream content = (InputStream) url.getContent(); if (content != null) { BufferedReader br = new BufferedReader(new InputStreamReader(content)); String downloadedMD5 = ""; try { downloadedMD5 = br.readLine().split(" ")[0]; } catch (NullPointerException e) { throw new IOException("md5_verification : no sum on server"); } if (!MD5.checkMD5(downloadedMD5, output)) { throw new IOException("md5_verification : incorrect"); } } } PendingIntent pendingIntent = (PendingIntent) intent .getParcelableExtra(EXTRA_PENDING_FINISH_INTENT); try { Runtime.getRuntime().exec("chmod 644 " + outPath); } catch (IOException e) { Log.e(THIS_FILE, "Unable to make the apk file readable", e); } Log.d(THIS_FILE, "Download finished of : " + outPath); if (pendingIntent != null) { notification.contentIntent = pendingIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; notification.icon = android.R.drawable.stat_sys_download_done; notification.contentView.setViewVisibility(R.id.status_progress_wrapper, View.GONE); notification.contentView.setTextViewText(R.id.status_text, getResources().getString(R.string.done) // TODO should be a parameter of this class + " - Click to install"); notificationManager.notify(NOTIF_DOWNLOAD, notification); /* try { pendingIntent.send(); notificationManager.cancel(NOTIF_DOWNLOAD); } catch (CanceledException e) { Log.e(THIS_FILE, "Impossible to start pending intent for download finish"); } */ } else { Log.w(THIS_FILE, "Invalid pending intent for finish !!!"); } result = Activity.RESULT_OK; } } catch (IOException e) { Log.e(THIS_FILE, "Exception in download", e); } } if (result == Activity.RESULT_CANCELED) { notificationManager.cancel(NOTIF_DOWNLOAD); } }