gpt4 book ai didi

Android程序连接Facebook : LoginActivity has leaked window

转载 作者:行者123 更新时间:2023-11-29 14:39:12 27 4
gpt4 key购买 nike

这是 Facebook 自己提供的基本程序 - 将 Android 应用程序连接到 Facebook:但我似乎得到一个错误:

Activity com.Facebook.LoginActivity has leaked window com.android.internal.policy.impl.PhoneWindow@DecorView@40512630 最初添加在这里:

尝试了以下方法:

  • 我已经验证了我的 keyHash
  • 我已经验证了我的 Android.xml
  • 我在论坛上寻找更多意见。

有什么建议吗???

主要 Activity :

package com.example.facebookconnectionapp;

import com.facebook.Request;
import com.facebook.Response;
import com.facebook.Session;
import com.facebook.SessionState;
import com.facebook.model.GraphUser;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.widget.TextView;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

Log.i("Facebook Activity", "Before opening session");

Session.openActiveSession(this, true, new Session.StatusCallback() {

@Override
public void call(Session session, SessionState state, Exception exception) {
// TODO Auto-generated method stub

Log.i("Facebook Activity", "Checking if session open");

if(session.isOpened()){

Log.i("Facebook Activity", "Session is open");
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

@Override
public void onCompleted(GraphUser user, Response response) {
// TODO Auto-generated method stub

Log.i("Facebook Activity", "Inside GraphCallback");

TextView textView = (TextView) findViewById(R.id.textView1);
textView.setText(user.getUsername());
}
});
} else {

Log.i("Facebook Activity", "Session not open");
}

}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);

Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}

}

AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.facebookconnectionapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.facebookconnectionapp.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
<activity android:name="com.facebook.LoginActivity"></activity>
</application>

</manifest>

最佳答案

确保您已连接到互联网。如果不是,您将收到此错误。

关于Android程序连接Facebook : LoginActivity has leaked window,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17647444/

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