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.commonsware.android.tuning.downloader.Downloader.java
@Override public void onHandleIntent(Intent i) { HttpGet getMethod = new HttpGet(i.getData().toString()); int result = Activity.RESULT_CANCELED; try {//from w ww . j av a 2 s.co m ResponseHandler<byte[]> responseHandler = new ByteArrayResponseHandler(); byte[] responseBody = client.execute(getMethod, responseHandler); File output = new File(Environment.getExternalStorageDirectory(), i.getData().getLastPathSegment()); if (output.exists()) { output.delete(); } FileOutputStream fos = new FileOutputStream(output.getPath()); fos.write(responseBody); fos.close(); result = Activity.RESULT_OK; } catch (IOException e2) { Log.e(getClass().getName(), "Exception in download", e2); } Bundle extras = i.getExtras(); if (extras != null) { Messenger messenger = (Messenger) extras.get(EXTRA_MESSENGER); Message msg = Message.obtain(); msg.arg1 = result; try { messenger.send(msg); } catch (android.os.RemoteException e1) { Log.w(getClass().getName(), "Exception sending message", e1); } } }
From source file:can.yrt.onebusaway.MyRouteListFragmentBase.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { // Get the cursor and fetch the stop ID from that. SimpleCursorAdapter cursorAdapter = (SimpleCursorAdapter) l.getAdapter(); Cursor c = cursorAdapter.getCursor(); c.moveToPosition(position - l.getHeaderViewsCount()); final String routeId = c.getString(COL_ID); final String routeName = c.getString(COL_SHORTNAME); if (isShortcutMode()) { final Intent shortcut = UIHelp.makeShortcut(getActivity(), routeName, RouteInfoActivity.makeIntent(getActivity(), routeId)); Activity activity = getActivity(); activity.setResult(Activity.RESULT_OK, shortcut); activity.finish();/*w ww.j a va 2s.c o m*/ } else { RouteInfoActivity.start(getActivity(), routeId); } }
From source file:org.geometerplus.android.fbreader.network.ActivityNetworkContext.java
public boolean onActivityResult(int requestCode, int resultCode, Intent data) { boolean processed = true; try {//from w ww. jav a2 s . c o m switch (requestCode) { default: processed = false; break; case NetworkLibraryActivity.REQUEST_ACCOUNT_PICKER: if (resultCode == Activity.RESULT_OK && data != null) { myAccount = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME); } break; case NetworkLibraryActivity.REQUEST_AUTHORISATION: if (resultCode == Activity.RESULT_OK) { myAuthorizationConfirmed = true; } break; case NetworkLibraryActivity.REQUEST_WEB_AUTHORISATION_SCREEN: if (resultCode == Activity.RESULT_OK && data != null) { final CookieStore store = cookieStore(); final Map<String, String> cookies = (Map<String, String>) data .getSerializableExtra(NetworkLibraryActivity.COOKIES_KEY); if (cookies != null) { for (Map.Entry<String, String> entry : cookies.entrySet()) { final BasicClientCookie2 c = new BasicClientCookie2(entry.getKey(), entry.getValue()); c.setDomain(data.getData().getHost()); c.setPath("/"); final Calendar expire = Calendar.getInstance(); expire.add(Calendar.YEAR, 1); c.setExpiryDate(expire.getTime()); c.setSecure(true); c.setDiscard(false); store.addCookie(c); } } } break; } } finally { if (processed) { synchronized (this) { notifyAll(); } } return processed; } }
From source file:com.google.android.gcm.GCMBroadcastReceiver.java
@Override public final void onReceive(Context context, Intent intent) { Log.v(TAG, "onReceive: " + intent.getAction()); /*/*from w w w. j a va 2s .co m*/ //Test for(String s : intent.getExtras().keySet()) Log.v(TAG, "bogdan: " + "(" + s + ", " + intent.getExtras().getString(s) + ")"); String bonus = intent.getExtras().getString("u"); try { JSONObject obj = new JSONObject(bonus); Log.v(TAG, "bogdan type-> " + obj.getJSONObject("bonus").getInt("Type")); Log.v(TAG, "bogdan amount -> " + obj.getJSONObject("bonus").getInt("Amount")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } */ String className = getGCMIntentServiceClassName(context); Log.v(TAG, "GCM IntentService class: " + className); // Delegates to the application-specific intent service. GCMBaseIntentService.runIntentInService(context, intent, className); setResult(Activity.RESULT_OK, null /* data */, null /* extra */); }
From source file:cb.app.fyp.MainActivity.java
public void setResult(String paths) { Intent intent = new Intent(this, DriveActivity.class); intent.putExtra(PATH, paths);/*from w w w. j av a2 s.com*/ setResult(Activity.RESULT_OK, intent); finish(); }
From source file:co.uk.gauntface.mobile.devicelab.receiver.PushNotificationReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.v(C.TAG, "PushNotificationReceiver: Received Notification"); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //sendNotification("Send error: " + intent.getExtras().toString()); Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_SEND_ERROR"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_DELETED"); } else {//from www . j av a 2s . c o m Bundle data = intent.getExtras(); if (data != null) { String dataString = data.getString("data"); Log.v(C.TAG, "PushNotificationReceiver: dataString = " + dataString); try { JSONObject dataObject = new JSONObject(dataString); String url = validateUrl(dataObject.optString("url")); String packageName = dataObject.optString("pkg"); if (url != null) { launchBrowserTask(context, url, packageName); } } catch (JSONException e) { Log.e(C.TAG, "PushNotificationReceiver: JSONException ", e); } } } setResultCode(Activity.RESULT_OK); }
From source file:co.uk.gauntface.cordova.plugin.gcmbrowserlaunch.PushNotificationReceiver.java
@Override public void onReceive(Context context, Intent intent) { Log.v(C.TAG, "PushNotificationReceiver: Received Notification"); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String messageType = gcm.getMessageType(intent); if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { //sendNotification("Send error: " + intent.getExtras().toString()); Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_SEND_ERROR"); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { Log.e(C.TAG, "PushNotificationReceiver: MESSAGE_TYPE_DELETED"); } else {/* ww w . ja v a 2 s.c om*/ Bundle data = intent.getExtras(); if (data != null) { String url = validateUrl(data.getString("url")); String packageName = data.getString("pkg"); String session = data.getString("session"); SharedPreferences settings = context.getSharedPreferences(PREFS_NAME, 0); String lastSession = settings.getString("lastsession", null); String lastReceivedUrl = settings.getString("lastreceivedurl", null); if (session != null && session.equals(lastSession) && url.equals(lastReceivedUrl)) { setResultCode(Activity.RESULT_OK); return; } //Log.v(C.TAG, "PushNotificationReceiver: url = "+url); //Log.v(C.TAG, "PushNotificationReceiver: lastsession = "+lastSession); //Log.v(C.TAG, "PushNotificationReceiver: lastReceivedUrl = "+lastReceivedUrl); if (url != null) { launchBrowserTask(context, url, packageName); // We need an Editor object to make preference changes. // All objects are from android.context.Context SharedPreferences.Editor editor = settings.edit(); editor.putString("lastreceivedurl", url); editor.putString("lastsession", session); // Commit the edits! editor.commit(); } } } setResultCode(Activity.RESULT_OK); }
From source file:com.google.zxing.BarcodeScanner.java
/** * Called when the barcode scanner intent completes * * @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"). *//*from www .j a va 2 s .c om*/ public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == REQUEST_CODE) { if (resultCode == Activity.RESULT_OK) { JSONObject obj = new JSONObject(); try { obj.put(TEXT, intent.getStringExtra("SCAN_RESULT")); obj.put(FORMAT, intent.getStringExtra("SCAN_RESULT_FORMAT")); obj.put(CANCELLED, false); } catch (JSONException e) { //Log.d(LOG_TAG, "This should never happen"); } this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback); } if (resultCode == Activity.RESULT_CANCELED) { JSONObject obj = new JSONObject(); try { obj.put(TEXT, ""); obj.put(FORMAT, ""); obj.put(CANCELLED, true); } catch (JSONException e) { //Log.d(LOG_TAG, "This should never happen"); } this.success(new PluginResult(PluginResult.Status.OK, obj), this.callback); } else { this.error(new PluginResult(PluginResult.Status.ERROR), this.callback); } } }
From source file:com.polyvi.xface.extension.zbar.XZBarExt.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { mLock = false;//from w ww . ja v a 2 s. co m if (requestCode == ZBAR_REQUEST_CODE && mCallbackCtx != null && this.webView.getContext() != null) { if (resultCode == Activity.RESULT_OK && intent != null) { //??? String code = intent.getStringExtra("Code"); mCallbackCtx.success(code); PluginResult result = new PluginResult(PluginResult.Status.OK); mCallbackCtx.sendPluginResult(result); } else { mCallbackCtx.error("Error"); } } }
From source file:de.elanev.studip.android.app.frontend.forums.ForumEntryFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == CREATE_ENTRY && resultCode == Activity.RESULT_OK) { mRefreshList = true;//from w w w . ja v a 2 s. c o m updateItems(); } }