gpt4 book ai didi

java - 谷歌登录 fragment 中出现错误,W/IInputConnectionWrapper(20367) : showStatusIcon on inactive InputConnection

转载 作者:太空宇宙 更新时间:2023-11-04 13:52:10 27 4
gpt4 key购买 nike

当我点击 google 登录按钮时出现此错误:W/IInputConnectionWrapper(20367):在非 Activity 的 InputConnection 上显示StatusIcon 但我不知道我是怎么遇到这个问题的,我读到这个错误是由于连接未提前关闭造成的,但不明白是什么。请有人帮助我

  `*package com.amuse.facebooktutorial;
public class GoogleLoginFragment extends Fragment implements OnClickListener,
ConnectionCallbacks, OnConnectionFailedListener {
private static final int RC_SIGN_IN = 0;
private static final int RESULT_OK = 0;
// Logcat tag
private static final String TAG = "MainActivity";
// Google client to interact with Google API
private GoogleApiClient mGoogleApiClient;
private static final int REQ_SIGN_IN_REQUIRED = 55664;
/**
* A flag indicating that a PendingIntent is in progress and prevents us
* from starting further intents.
*/
private boolean mIntentInProgress;
private boolean mSignInClicked;
private ConnectionResult mConnectionResult;
private SignInButton btnSignIn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
View view = inflater.inflate(R.layout.google_login_layout, container, false);

btnSignIn = (SignInButton) view.findViewById(R.id.google_login_button);


mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN).build();


btnSignIn.setOnClickListener(this);
try {
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi
.getCurrentPerson(mGoogleApiClient);

String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
String id = currentPerson.getId()+"$GOOGLE";
String token = new RetrieveTokenTask().execute(email).toString();



((MainActivity)getActivity()).googleLogin(id, token);
} else {
Toast.makeText(getActivity(),
"Person information is null", Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
e.printStackTrace();
}

return view;


}
public void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
public void onStop() {
super.onStop();
if (mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnect();
}
}
/**
* Method to resolve any signin errors
* */
private void resolveSignInError() {
if (mConnectionResult.hasResolution()) {
try {
mIntentInProgress = true;
mConnectionResult.startResolutionForResult(getActivity(), RC_SIGN_IN);
} catch (SendIntentException e) {
mIntentInProgress = false;
mGoogleApiClient.connect();
}
}
}
@Override
public void onConnectionFailed(ConnectionResult result) {
if (!result.hasResolution()) {
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), getActivity(),
0).show();
return;
}
if (!mIntentInProgress) {
// Store the ConnectionResult for later usage
mConnectionResult = result;
if (mSignInClicked) {
// The user has already clicked 'sign-in' so we attempt to
// resolve all
// errors until the user is signed in, or they cancel.
resolveSignInError();
}
}
}
@Override
public void onActivityResult(int requestCode, int responseCode,
Intent intent) {
if (requestCode == RC_SIGN_IN) {
if (responseCode != RESULT_OK) {
mSignInClicked = false;
}
mIntentInProgress = false;
if (!mGoogleApiClient.isConnecting()) {
mGoogleApiClient.connect();
}
}
}

@Override
public void onConnected(Bundle Bundle) {
mSignInClicked = false;
Toast.makeText(getActivity(), "User is connected!", Toast.LENGTH_LONG).show();
}
@Override
public void onConnectionSuspended(int arg0) {
mGoogleApiClient.connect();
}
/**
* Button on click listener
* */
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.google_login_button:
// Signin button clicked
signInWithGplus();
break;
}
}
/**
* Sign-in into google
* */
private void signInWithGplus() {
if (!mGoogleApiClient.isConnecting()) {
mSignInClicked = true;
resolveSignInError();
}
}
private class RetrieveTokenTask extends AsyncTask<String, String, String> {

@Override
protected String doInBackground(String... params) {
String accountName = params[0];
String scopes = "oauth2:profile email";
String token = null;
try {
token = GoogleAuthUtil.getToken(getActivity().getApplicationContext(), accountName, scopes);
Log.e("token", token);
} catch (IOException e) {
Log.e(TAG, e.getMessage());
} catch (UserRecoverableAuthException e) {
startActivityForResult(e.getIntent(), REQ_SIGN_IN_REQUIRED);
} catch (GoogleAuthException e) {
Log.e(TAG, e.getMessage());
}
return token;
}
}
}*
`

最佳答案

第一您需要检查 AndroidManifest.xml 文件。检查拥有 GoogleLoginFragment 的 Activity 是否已设置 noHistory="true"属性。

第二您需要检查您的服务器连接在之前的类(class)或 Activity 中是否已关闭。

我希望这会有所帮助。

关于java - 谷歌登录 fragment 中出现错误,W/IInputConnectionWrapper(20367) : showStatusIcon on inactive InputConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30188557/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com