Reputation: 461
I cant open a session in facebook's latest sdk in android. When I debug my code it shows session state:"OPENING" -> not "OPEN". I am stacked in this issue for couple days and there is no such kind of problem on internet, so please help me. Here is my example Main Class:
public class Miranda extends Activity {
/**
* Called when the activity is first created.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final TextView userNameView = (TextView) findViewById(R.id.userName);
Session.openActiveSession(this, true, new Session.StatusCallback() {
// callback when session changes state
@Override
public void call(Session session, SessionState state, Exception exception) {
if (session.isOpened()) {
// make request to the /me API
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {
// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {
if (user != null) {
userNameView.setText("Hello " + user.getName() + "!");
// profilePictureView.setProfileId(user.getId());
}
}
});
}
}
});
}
}
And here is AndroidManifest.xml :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.Miranda"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8"/>
<application android:label="@string/app_name">
<activity android:name="Miranda"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.facebook.LoginActivity"
android:label="@string/title_facebook_login">
</activity>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/app_id"/>
</application>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
and lastly strings.xml :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Miranda</string>
<string name="app_id">241765162664333</string>
<string name="title_facebook_login">Log Into Facebook</string>
</resources>
Upvotes: 2
Views: 1783
Reputation: 461
Guys I can be the fastest man who solves his problem immediately after telling it in stackoverflow. The problem was: I deleted an overridden function when cleaning other stupid trying codes. I added it again into my main class:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
Upvotes: 6