android 无法添加帐户,android – 添加帐户(设置)方法无法启动Activity

在尝试在设置中创建自定义应用帐户时,遇到一个图标显示的添加帐户选项,点击后AuthenticatorActivity并未启动。已检查Authenticator类并调用addAccount方法,但没有弹出任何活动。问题可能出在Intent的传递或AuthenticatorActivity的配置上。
摘要由CSDN通过智能技术生成

我想在设置中创建自定义应用帐户.

问题

>设置中有一个带图标的选项>添加帐户但没有名称

>单击该(添加帐户)时,AuthenticatorActivity不会启动.我调试Authenticator类,调用addAccount方法但没有弹出任何活动.

我做了以下步骤:

认证类(部分)

public class AccountAuthenticator extends AbstractAccountAuthenticator{

@Override

public Bundle addAccount(AccountAuthenticatorResponse response,

String accountType, String authTokenType,

String[] requiredFeatures, Bundle options)

throws NetworkErrorException {

final Intent intent = new Intent(mContext, AuthenticatorActivity.class);

intent.putExtra(AuthenticatorActivity.ARG_ACCOUNT_TYPE, accountType);

intent.putExtra(AuthenticatorActivity.ARG_AUTH_TYPE, authTokenType);

intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);

intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

final Bundle bundle = new Bundle();

bundle.putParcelable(AccountAuthenticator.KEY_INTENT, intent);

return bundle;

}

}

AuthenticatorService

public class AuthenticatorService extends Service{

@Override

public IBinder onBind(Intent intent) {

authenticator = new AccountAuthenticator(this);

return authenticator.getIBinder();

}

}

表现

android:label="@string/app_name">

android:resource="@xml/authenticator" />

authenticator xml

android:accountType="com.example.myapp"

android:icon="@drawable/myapp_icon"

android:smallIcon="@drawable/myapp_icon_small"

android:label="myapp"

/>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值