Java google登录片段中出错,W/IInputConnectionWrapper(20367):非活动InputConnection上的showStatusIcon
单击google登录按钮时出现此错误: 带IIInputConnectionWrapper(20367):在非活动InputConnection上显示状态图标 但我不知道我怎么会有这个问题,我读到这个错误是由于一个连接没有关闭之前,但不明白什么。请有人帮帮我Java google登录片段中出错,W/IInputConnectionWrapper(20367):非活动InputConnection上的showStatusIcon,java,android,android-fragments,google-login,Java,Android,Android Fragments,Google Login,单击google登录按钮时出现此错误: 带IIInputConnectionWrapper(20367):在非活动InputConnection上显示状态图标 但我不知道我怎么会有这个问题,我读到这个错误是由于一个连接没有关闭之前,但不明白什么。请有人帮帮我 `*package com.amuse.facebooktutorial; public class GoogleLoginFragment extends Fragment implements OnClickListener
`*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;
}
}
}*
`
`*package com.amuse.facebook教程;
公共类GoogleLoginFragment扩展了片段实现OnClickListener,
ConnectionCallbacks,OnConnectionFailedListener{
私有静态最终int RC_SIGN_IN=0;
私有静态最终整数结果_OK=0;
//Logcat标签
私有静态最终字符串TAG=“MainActivity”;
//Google客户端与Google API交互
私人GoogleapClient MGoogleapClient;
专用静态最终整数要求符号要求=55664;
/**
*一种标志,表明悬挂式帐篷正在进行中并阻止我们
*从开始进一步的意图。
*/
私有布尔mIntentInProgress;
私有布尔msignincled;
私有连接结果mConnectionResult;
私人签名按钮;
@凌驾
创建时的公共void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
}
@凌驾
创建视图上的公共视图(布局、充气机、视图组容器、,
Bundle savedInstanceState){
//TODO自动生成的方法存根
视图=充气机。充气(R.layout.google\u login\u布局,容器,false);
btnSignIn=(SignInButton)view.findViewById(R.id.google\u login\u按钮);
mgoogleapclient=新的Googleapclient.Builder(getActivity())
.addConnectionCallbacks(此)
.addOnConnectionFailedListener(this).addApi(Plus.API)
.addScope(Plus.SCOPE\u Plus\u LOGIN).build();
btnSignIn.setOnClickListener(此);
试一试{
if(Plus.PeopleApi.getCurrentPerson(mGoogleApiClient)!=null){
Person currentPerson=Plus.PeopleApi
.getCurrentPerson(MGoogleapClient);
字符串email=Plus.AccountApi.getAccountName(mGoogleApiClient);
字符串id=currentPerson.getId()+“$GOOGLE”;
String token=new RetrieveTokenTask().execute(email.toString();
((MainActivity)getActivity()).googleLogin(id,令牌);
}否则{
Toast.makeText(getActivity(),
“人员信息为空”,Toast.LENGTH_LONG.show();
}
}捕获(例外e){
e、 printStackTrace();
}
返回视图;
}
public void onStart(){
super.onStart();
mGoogleApiClient.connect();
}
公共void onStop(){
super.onStop();
if(mgoogleapClient.isConnected()){
mGoogleApiClient.disconnect();
}
}
/**
*方法来解决任何登录错误
* */
私有无效解析错误(){
if(mcConnectionResult.hasResolution()){
试一试{
mIntentInProgress=true;
mcConnectionResult.startResolutionForResult(getActivity(),RC\u SIGN\u IN);
}捕获(发送){
mIntentInProgress=false;
mGoogleApiClient.connect();
}
}
}
@凌驾
连接失败的公共void(连接结果){
如果(!result.hasResolution()){
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(),getActivity(),
0)show();
回来
}
如果(!mIntentInProgress){
//存储ConnectionResult供以后使用
mConnectionResult=结果;
如果(mSignInClicked){
//用户已单击“登录”,因此我们尝试
//解决所有问题
//错误,直到用户登录或取消。
ResolveSignError();
}
}
}
@凌驾
在ActivityResult(int请求代码、int响应代码、,
意图(意图){
if(requestCode==RC\u登录){
if(responseCode!=结果\u正常){
mSignInClicked=false;
}
mIntentInProgress=false;
如果(!mgoogleapClient.isConnecting()){
mGoogleApiClient.connect();
}
}
}
@凌驾
未连接的公共空间(捆绑包){
mSignInClicked=false;
Toast.makeText(getActivity(),“用户已连接!”,Toast.LENGTH_LONG.show();
}
@凌驾
连接上的公共无效已暂停(int arg0){
mGoogleApiClient.connect();
}
/**
*单击侦听器上的按钮
* */
@凌驾
公共void onClick(视图v){
开关(v.getId()){
案例R.id.google\u登录按钮:
//已单击登录按钮
用gplus()表示;
打破
}
}
/**
*登录谷歌
* */
私有void signInWithGplus(){
如果(!mgoogleapClient.isConnecting()){
mSignInClicked=true;
ResolveSignError();
}
}
私有类RetrieveTokenTask扩展异步任务{
@凌驾
受保护的字符串doInBackground(字符串…参数){
字符串accountName=params[0];
String scopes=“oauth2:配置文件电子邮件”;
字符串标记=null;
试一试{
token=GoogleAuthUtil.getToken(getActivity().getApplicationContext(),accountName,scopes);
Log.e(“令牌”,令牌);
}捕获(IOE异常){
Log.e(标记,e.getMessage());
}捕获(UserRecoverableAuthe异常){
startActivityForResult(如getIntent(),需要签名);
}捕获(googleauthe异常){
Log.e(标记,e.getMessage());
}
返回令牌;
}
}
}*
`
首先
您需要检查AndroidManifest.xml文件。
检查拥有GoogleLoginFragment的活动是否已设置为noHisto