@Override protected void onPostExecute(Connection.Response response) { if (response != null && response.statusCode() == 200) { try { Log.v(TAG, "Response to JSON request: " + response.body()); JSONObject root = new JSONObject(response.body()); boolean success = "success".equals(root.getString("type")); int points = root.getInt("points"); IHasEnterableGiveaways fragment = getFragment(); fragment.onEnterLeaveResult(giveawayId, getWhat(), success, true); // Update the points we have. SteamGiftsUserData.getCurrent().setPoints(points); if (fragment instanceof Fragment && "error".equals(root.getString("type")) && "Sync Required".equals(root.getString("msg"))) { ((Fragment) fragment) .getActivity() .startActivity(new Intent(((Fragment) fragment).getContext(), SyncActivity.class)); } return; } catch (JSONException e) { Log.e(TAG, "Failed to parse JSON object", e); } } getFragment().onEnterLeaveResult(giveawayId, getWhat(), null, false); }
protected void startActivity(Intent intent) { if (fragment != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { fragment.startActivity(intent); } } else if (supportFragment != null) { supportFragment.startActivity(intent); } else { activity.startActivity(intent); } }
/** * Shares the given text by encoding it as a barcode, such that another user can scan the text off * the screen of the device. * * @param text the text string to encode as a barcode * @param type type of data to encode. See {@code com.google.zxing.client.android.Contents.Type} * constants. * @return the {@link AlertDialog} that was shown to the user prompting them to download the app * if a prompt was needed, or null otherwise */ public final AlertDialog shareText(CharSequence text, CharSequence type) { Intent intent = new Intent(); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setAction(BS_PACKAGE + ".ENCODE"); intent.putExtra("ENCODE_TYPE", type); intent.putExtra("ENCODE_DATA", text); String targetAppPackage = findTargetAppPackage(intent); if (targetAppPackage == null) { return showDownloadDialog(); } intent.setPackage(targetAppPackage); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); attachMoreExtras(intent); if (fragment == null) { activity.startActivity(intent); } else { fragment.startActivity(intent); } return null; }
protected void register() { mFragment.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.Url.OSM_REGISTER))); }
protected void recoverPassword() { mFragment.startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.Url.OSM_RECOVER_PASSWORD))); }
public void startActivity(Intent intent) { zzadh.startActivity(intent); }