我们在帐户套件中收到以下错误。
如果有人能说出原因以及如何解决问题,将会非常有帮助。
java.lang.RuntimeException:
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4155)
at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4246)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3360)
at android.app.ActivityThread.access$1100 (ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1794)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:158)
at android.app.ActivityThread.main (ActivityThread.java:7225)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
Caused by: java.lang.ArrayIndexOutOfBoundsException:
at com.facebook.accountkit.ui.PhoneCountryCodeAdapter.getItem (PhoneCountryCodeAdapter.java:253)
at com.facebook.accountkit.ui.PhoneContentController$TopFragment.setPhoneNumberText (PhoneContentController.java:435)
at com.facebook.accountkit.ui.PhoneContentController$TopFragment.onViewReadyWithState (PhoneContentController.java:362)
at com.facebook.accountkit.ui.ViewStateFragment.onActivityCreated (ViewStateFragment.java:66)
at com.facebook.accountkit.ui.PhoneContentController$TopFragment.onActivityCreated (PhoneContentController.java:201)
at android.app.Fragment.performActivityCreated (Fragment.java:2289)
at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1007)
at android.app.FragmentManagerImpl.moveToState (FragmentManager.java:1163)
at android.app.BackStackRecord.run (BackStackRecord.java:793)
at android.app.FragmentManagerImpl.execPendingActions (FragmentManager.java:1552)
at android.app.FragmentController.execPendingActions (FragmentController.java:325)
at android.app.Activity.performResume (Activity.java:7014)
at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4144)
所以行Caused by: java.lang.ArrayIndexOutOfBoundsException:
at com.facebook.accountkit.ui.PhoneCountryCodeAdapter.getItem
是由于在facebook库中编写的一段代码引起的?或者它是我们可以控制的东西,并通过使用配置文件等以某种方式改变?
我们只是在我们的应用中使用https://developers.facebook.com/docs/accountkit/android。它工作得很好,但是有些设备出现了错误。
在调用accountkit的活动中跟随onCreate的代码。我们没有使用onResume。
SkinManager uiManager = new SkinManager(
SkinManager.Skin.CONTEMPORARY,
getResources().getColor(R.color.colorPrimary),
R.drawable.login_bg2,
SkinManager.Tint.WHITE,
0.55D);
intent = new Intent(this, AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
LoginType.PHONE,
AccountKitActivity.ResponseType.TOKEN); // or .ResponseType.TOKEN
configurationBuilder.setSMSWhitelist(new String[]{"PK"});
configurationBuilder.setUIManager(uiManager);
intent.putExtra(
AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
configurationBuilder.build());
响应 开始得到回应。
startActivityForResult(intent, APP_REQUEST_CODE);
我们正在处理响应
@Override
protected void onActivityResult(
final int requestCode,
final int resultCode,
final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == APP_REQUEST_CODE) {
btnContinue.setEnabled(true);
// confirm that this response matches your request
final AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
if (loginResult.getError() != null) {
} else if (loginResult.wasCancelled()) {
} else {
progressDialog.show();
if(loginResult.getAccessToken()!=null){
fbAccessToken = loginResult.getAccessToken().getToken();
}
AccountKit.getCurrentAccount(new AccountKitCallback<Account>() {
@Override
public void onSuccess(Account account) {
PhoneNumber phoneNumber = account.getPhoneNumber();
phoneNumberString = phoneNumber.getPhoneNumber();
// some bla bla to call our APIs to save the response
}
@Override
public void onError(AccountKitError accountKitError) {
Log.e(TAG, "onError");
progressDialog.hide();
Toast.makeText(SignInActivity.this, accountKitError.getUserFacingMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
}
答案 0 :(得分:0)
您必须致电
configurationBuilder.setDefaultCountryCode(“ PH”);
我也为此问题困扰了很长时间。
答案 1 :(得分:0)
这是我的最终代码。
public class AccountKitLoginManager {
public final static int APP_REQUEST_CODE = 99;
public static void login(Activity activity){
final Intent intent = new Intent(activity, AccountKitActivity.class);
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
LoginType.PHONE,
AccountKitActivity.ResponseType.CODE).setSMSWhitelist(new String[]{"MM"}); // or .ResponseType.TOKEN
intent.putExtra(
AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
configurationBuilder.build());
activity.startActivityForResult(intent, APP_REQUEST_CODE);
}
}
第一个错误与您相同。此代码的原因是String [] {“ MM,CN”}。所以我删除了CN。我的程序很好。