Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.app.Activity;
import android.content.SharedPreferences;

import android.util.Log;

public class Main {
    public static final String TAG = "OAuthHelper";
    public static final String PREF_AUTH_TOKEN = "authToken";
    public static final String PREF_ACCOUNT_NAME = "accountName";

    /**
     * Forget the account name and authToken. With no account name the app will
     * prompt the user to select a new account. This method is mostly used for
     * testing purposes.
     * 
     * @param activity
     */
    public static void resetAccountCredential(Activity activity) {
        Log.i(TAG, "Reset credentials");
        SharedPreferences settings = activity.getPreferences(Activity.MODE_PRIVATE);
        SharedPreferences.Editor editor2 = settings.edit();
        editor2.remove(PREF_AUTH_TOKEN);
        editor2.remove(PREF_ACCOUNT_NAME);
        editor2.commit();
    }
}