2014-01-03 3 views
1

Я создаю приложение, и я хочу очистить данные пользователя для входа в систему Facebook для пользователя. Поскольку, когда он сохраняет данные, он каждый раз использует одни и те же данные, но я хочу, чтобы он запрашивал у пользователя Войти каждый раз, когда пользователь открывает приложение?очистить регистрационную информацию пользователя для каждого входа

+1

Вы используете facebook SDK или просто открываете URL-адрес в веб-просмотре? –

+0

m используя facebook sdk .. –

ответ

1

Запишите следующие утверждения вместе с Webview.

myWebView.clearCache(true); 
myContext.deleteDatabase("webview.db"); 
myContext.deleteDatabase("webviewCache.db"); 
0

Здравствуйте Amit,

При входе в фейсбуке затем facebook дал вам "SESSIONID", и Используйте facebook эту сессию каждый раз.

Если вы хотите каждый раз при входе в систему, вы можете написать код «Выход» на кнопку назад.

+0

Этот ответ применяется, когда вы использовали Facebook SDk – AndroidDanger

+0

Я использую facebook sdk, но его не работает? –

+0

Код выхода не работает здесь, после того, как он получает регистрационные данные для пользователя, который хранит их до тех пор, пока приложение не будет удалено ... –

1

Если вы не используете ни одну банку и не используете классы библиотеки, то следующий фрагмент кода для вашего понимания.

От Facebook.java

Статические переменные, которые используются для вызова активности для журнала в диалоге.

public static final int FORCE_DIALOG_AUTH = -1; 

private static final String LOGIN = "oauth"; 

// Used as default activityCode by authorize(). See authorize() below. 
private static final int DEFAULT_AUTH_ACTIVITY_CODE = 32665; 

следующий метод авторизированным этого класса, чтобы разрешить пользователю, и вместо того, чтобы использовать DEFAULT_AUTH_ACTIVITY_CODE если вы используете FORCE_DIALOG_AUTH ваше приложение предложит вам логарифмически каждый раз.

/** 
* Authorize method that grants custom permissions. 
* 
* See authorize() below for @params. 
*/ 
public void authorize(Activity activity, String[] permissions, 
     final DialogListener listener) { 
    authorize(activity, permissions, DEFAULT_AUTH_ACTIVITY_CODE, listener); 
} 

другой метод авторизации в этом классе Facebook.java выглядит следующим образом, и этот метод вызывают вас для единого входа (SSO). Для получения дополнительной информации вы можете проверить комментарии этого метода, которые я включил в этот ответ.

/** 
* Full authorize method. 
* 
* Starts either an Activity or a dialog which prompts the user to log in to 
* Facebook and grant the requested permissions to the given application. 
* 
* This method will, when possible, use Facebook's single sign-on for 
* Android to obtain an access token. This involves proxying a call through 
* the Facebook for Android stand-alone application, which will handle the 
* authentication flow, and return an OAuth access token for making API 
* calls. 
* 
* Because this process will not be available for all users, if single 
* sign-on is not possible, this method will automatically fall back to the 
* OAuth 2.0 User-Agent flow. In this flow, the user credentials are handled 
* by Facebook in an embedded WebView, not by the client application. As 
* such, the dialog makes a network request and renders HTML content rather 
* than a native UI. The access token is retrieved from a redirect to a 
* special URL that the WebView handles. 
* 
* Note that User credentials could be handled natively using the OAuth 2.0 
* Username and Password Flow, but this is not supported by this SDK. 
* 
* See http://developers.facebook.com/docs/authentication/ and 
* http://wiki.oauth.net/OAuth-2 for more details. 
* 
* Note that this method is asynchronous and the callback will be invoked in 
* the original calling thread (not in a background thread). 
* 
* Also note that requests may be made to the API without calling authorize 
* first, in which case only public information is returned. 
* 
* IMPORTANT: Note that single sign-on authentication will not function 
* correctly if you do not include a call to the authorizeCallback() method 
* in your onActivityResult() function! Please see below for more 
* information. single sign-on may be disabled by passing FORCE_DIALOG_AUTH 
* as the activityCode parameter in your call to authorize(). 
* 
* @param activity 
*   The Android activity in which we want to display the 
*   authorization dialog. 
* @param applicationId 
*   The Facebook application identifier e.g. "350685531728" 
* @param permissions 
*   A list of permissions required for this application: e.g. 
*   "read_stream", "publish_stream", "offline_access", etc. see 
*   http://developers.facebook.com/docs/authentication/permissions 
*   This parameter should not be null -- if you do not require any 
*   permissions, then pass in an empty String array. 
* @param activityCode 
*   Single sign-on requires an activity result to be called back 
*   to the client application -- if you are waiting on other 
*   activities to return data, pass a custom activity code here to 
*   avoid collisions. If you would like to force the use of legacy 
*   dialog-based authorization, pass FORCE_DIALOG_AUTH for this 
*   parameter. Otherwise just omit this parameter and Facebook 
*   will use a suitable default. See 
*   http://developer.android.com/reference/android/ 
*    app/Activity.html for more information. 
* @param listener 
*   Callback interface for notifying the calling application when 
*   the authentication dialog has completed, failed, or been 
*   canceled. 
*/ 
public void authorize(Activity activity, String[] permissions, 
     int activityCode, final DialogListener listener) { 

    boolean singleSignOnStarted = false; 

    mAuthDialogListener = listener; 

    // Prefer single sign-on, where available. 
    if (activityCode >= 0) { 
     singleSignOnStarted = startSingleSignOn(activity, mAppId, 
       permissions, activityCode); 
    } 
    // Otherwise fall back to traditional dialog. 
    if (!singleSignOnStarted) { 
     startDialogAuth(activity, permissions); 
    } 
} 

EDIT:

enter image description here

Я говорю о инлайн библиотеки facebook, как показано выше рис. вам необходимо изменить с DEFAULT_AUTH_ACTIVITY_CODE на FORCE_DIALOG_AUTH, чтобы ваше приложение запрашивало учетные данные каждый раз, когда вы запрашиваете facebook.

+0

+1 для 'FORCE_DIALOG_AUTH', его новая вещь, которую я узнал. – Vigbyor

+0

Dinesh не могли бы вы рассказать подробнее? –

+0

Я отредактировал свой ответ, пожалуйста, проверьте его –

Смежные вопросы