Android Open Source - Gcal_Importer Andro Ics Authenticator






From Project

Back to project page Gcal_Importer.

License

The source code is released under:

Apache License

If you think the Android project Gcal_Importer 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 net.crappo.android.androics;
/* ww w.j ava  2  s.co  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.os.Bundle;

/* 
 * AccountAuthService.java?????????????????????????????????????????????Authenticator????
 * ???????????addAccount??????????????????????????
 */
public class AndroIcsAuthenticator extends AbstractAccountAuthenticator {
    private Context svcContext = null;

    public AndroIcsAuthenticator(Context context) {
        super(context);
        svcContext = context;
    }

    @Override
    public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options)
            throws NetworkErrorException {
        Bundle result = new Bundle();
        AccountManager acntMgr = AccountManager.get(svcContext);
        Account[] accounts = acntMgr.getAccountsByType(accountType);
        // ??????????????????????????????????
        if (null != accounts && accounts.length > 0) {
            result.putInt(AccountManager.KEY_ERROR_CODE, -1);
            result.putString(AccountManager.KEY_ERROR_MESSAGE, "Account Already Exist.");
            return result;
        }

        String userId = TopActivity.appName;
        Account account = new Account(userId, accountType);
        acntMgr.addAccountExplicitly(account, "DummyPasswd", null);
        result.putString(AccountManager.KEY_ACCOUNT_NAME, userId);
        result.putString(AccountManager.KEY_ACCOUNT_TYPE, accountType);

        return result;
    }

    @Override
    public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options)
            throws NetworkErrorException {
        return null;
    }

    @Override
    public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
        return null;
    }

    @Override
    public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)
            throws NetworkErrorException {
        return null;
    }

    @Override
    public String getAuthTokenLabel(String authTokenType) {
        return null;
    }

    @Override
    public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features)
            throws NetworkErrorException {
        return null;
    }

    @Override
    public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options)
            throws NetworkErrorException {
        return null;
    }

}




Java Source Code List

net.crappo.android.androics.AccountAuthService.java
net.crappo.android.androics.AndroIcsAuthenticator.java
net.crappo.android.androics.BrowserForDownLoadActivity.java
net.crappo.android.androics.Model4EventList.java
net.crappo.android.androics.Model4Top.java
net.crappo.android.androics.ShowEventListActivity.java
net.crappo.android.androics.ShowEventListAsync.java
net.crappo.android.androics.SimpleFileDialog.java
net.crappo.android.androics.TopActivity.java
net.crappo.android.androics.TopIcsListAsync.java
net.crappo.android.androics.ZipInOutMethods.java