Android Open Source - BikeStation Account Authenticator






From Project

Back to project page BikeStation.

License

The source code is released under:

GNU General Public License

If you think the Android project BikeStation listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.bikestation.app.account;
//from w  w w . j  a  v  a  2  s  . c  o m
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;

public class AccountAuthenticator extends AbstractAccountAuthenticator {

    public final static String ACCOUNT_TYPE = "com.kdravolin.smartlock.app";
    private Context mContext;
    private Handler mHandler;

    public AccountAuthenticator(Context context) {
        super(context);
        mContext = context;
        mHandler = new Handler();
    }

    @Override
    public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)
            throws NetworkErrorException {
        final Bundle result = new Bundle();
        final Intent intent;

//        AccountManager accountManager = AccountManager.get(mContext);
//        Account[] accounts = accountManager.getAccountsByType(accountType);
//        if (accounts.length > 0) {
//            final String message = mContext.getString(R.string.one_account_allowed);
//            result.putInt(AccountManager.KEY_ERROR_CODE, 0);
//            result.putString(AccountManager.KEY_ERROR_MESSAGE, message);
//
//            mHandler.post(new Runnable() {
//                @Override
//                public void run() {
//                    Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
//                }
//            });
//        } else {
//            intent = new Intent(this.mContext, AccountActivity.class);
//            intent.putExtra(accountType, authTokenType);
//            intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
//            result.putParcelable(AccountManager.KEY_INTENT, intent);
//        }
        return result;
    }

    @Override
    public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) throws NetworkErrorException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public String getAuthTokenLabel(String authTokenType) {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException {
        // TODO Auto-generated method stub
        return null;
    }

}




Java Source Code List

com.bikestation.app.BluetoothConnector.java
com.bikestation.app.BluetoothWorker.java
com.bikestation.app.ExtApp.java
com.bikestation.app.History.java
com.bikestation.app.Lock.java
com.bikestation.app.User.java
com.bikestation.app.account.AccountAuthenticator.java
com.bikestation.app.account.AuthenticationService.java
com.bikestation.app.activity.AccountActivity.java
com.bikestation.app.activity.BikesActivity.java
com.bikestation.app.activity.DeviceActivity.java
com.bikestation.app.activity.TimeActivity.java
com.bikestation.app.adapter.BikesAdapter.java
com.bikestation.app.adapter.DeviceAdapter.java