@Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Util.logd("Facebook-WebView", "Redirect URL: " + url); if (url.startsWith(Facebook.REDIRECT_URI)) { Bundle values = Util.parseUrl(url); String error = values.getString("error"); if (error == null) { error = values.getString("error_type"); } if (error == null) { mListener.onComplete(values); } else if (error.equals("access_denied") || error.equals("OAuthAccessDeniedException")) { mListener.onCancel(); } else { mListener.onFacebookError(new FacebookError(error)); } FbDialog.this.dismiss(); return true; } else if (url.startsWith(Facebook.CANCEL_URI)) { mListener.onCancel(); FbDialog.this.dismiss(); return true; } else if (url.contains(DISPLAY_STRING)) { return false; } // launch non-dialog URLs in a full browser getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; }
protected Void b(Void[] paramArrayOfVoid) { try { Settings.publishInstallAndWait(this.kz, this.ky); return null; } catch (Exception localException) { while (true) Util.logd("Facebook-publish", localException.getMessage()); } }
@Override public void onPageStarted(WebView view, String url, Bitmap favicon) { Util.logd("Facebook-WebView", "Webview loading URL: " + url); super.onPageStarted(view, url, favicon); try { mSpinner.show(); } catch (Exception ignored) { } }
@Override protected Void doInBackground(Void... voids) { try { Facebook.publishInstall(Facebook.this, mApplicationId, mApplicationContext); } catch (Exception e) { Util.logd("Facebook-publish", e.getMessage()); } return null; }
/** * Manually publish install attribution to the facebook graph. Internally handles tracking repeat * calls to prevent multiple installs being published to the graph. * * @param context * @return returns false on error. Applications should retry until true is returned. Safe to call * again after true is returned. */ public boolean publishInstall(final Context context) { try { // copy the application id to guarantee thread safety.. String applicationId = mAppId; if (applicationId != null) { publishInstall(this, applicationId, context); return true; } } catch (Exception e) { // if there was an error, fall through to the failure case. Util.logd("Facebook-publish", e.getMessage()); } return false; }
/** * IMPORTANT: This method must be invoked at the top of the calling activity's onActivityResult() * function or Facebook authentication will not function properly! * * <p>If your calling activity does not currently implement onActivityResult(), you must implement * it and include a call to this method if you intend to use the authorize() method in this SDK. * * <p>For more information, see http://developer.android.com/reference/android/app/ * Activity.html#onActivityResult(int, int, android.content.Intent) */ public void authorizeCallback(int requestCode, int resultCode, Intent data) { if (requestCode == mAuthActivityCode) { // Successfully redirected. if (resultCode == Activity.RESULT_OK) { // Check OAuth 2.0/2.10 error code. String error = data.getStringExtra("error"); if (error == null) { error = data.getStringExtra("error_type"); } // A Facebook error occurred. if (error != null) { if (error.equals(SINGLE_SIGN_ON_DISABLED) || error.equals("AndroidAuthKillSwitchException")) { Util.logd( "Facebook-authorize", "Hosted auth currently " + "disabled. Retrying dialog auth..."); startDialogAuth(mAuthActivity, mAuthPermissions); } else if (error.equals("access_denied") || error.equals("OAuthAccessDeniedException")) { Util.logd("Facebook-authorize", "Login canceled by user."); mAuthDialogListener.onCancel(); } else { String description = data.getStringExtra("error_description"); if (description != null) { error = error + ":" + description; } Util.logd("Facebook-authorize", "Login failed: " + error); mAuthDialogListener.onFacebookError(new FacebookError(error)); } // No errors. } else { setAccessToken(data.getStringExtra(TOKEN)); setAccessExpiresIn(data.getStringExtra(EXPIRES)); if (isSessionValid()) { Util.logd( "Facebook-authorize", "Login Success! access_token=" + getAccessToken() + " expires=" + getAccessExpires()); mAuthDialogListener.onComplete(data.getExtras()); } else { mAuthDialogListener.onFacebookError( new FacebookError("Failed to receive access token.")); } } // An error occurred before we could be redirected. } else if (resultCode == Activity.RESULT_CANCELED) { // An Android error occured. if (data != null) { Util.logd("Facebook-authorize", "Login failed: " + data.getStringExtra("error")); mAuthDialogListener.onError( new DialogError( data.getStringExtra("error"), data.getIntExtra("error_code", -1), data.getStringExtra("failing_url"))); // User pressed the 'back' button. } else { Util.logd("Facebook-authorize", "Login canceled by user."); mAuthDialogListener.onCancel(); } } } }