Ich versuche, einen Android-App mit der neuen Facebook 3.0 api zu integrieren, aber ich bekomme diese Ausnahme:aktualisiert - Android Facebook api 3.0 Fehler: Der Anruf kann nicht LoginActivity mit einem Null-calling Paket
java.lang.RuntimeException: Unable to resume activity {dk.imu.konnekt/com.facebook.LoginActivity}: com.facebook.FacebookException: Cannot call LoginActivity with a null calling package. This can occur if the launchMode of the caller is singleInstance.
Ich habe Suche nach diesem Fehler, aber niemand sonst scheint Probleme damit gehabt zu haben. Ich denke, es ist, weil ich ein TabHost und TabsGroupActivities für jede Registerkarte verwenden. Aber ich habe keine Ahnung, wie ich es lösen kann.
Ich habe den entsprechenden Code hier hinzugefügt:
public class MainTabActivity extends TabActivity {
public void onCreate(Bundle savedInstanteState){
super.onCreate(savedInstanteState);
setContentView(R.layout.tab_layout);
TabHost tabHost = getTabHost();
View shareTab = getLayoutInflater().inflate(R.layout.share_tab, null);
tabHost.addTab(tabHost.newTabSpec("Share").setIndicator(shareTab)
.setContent(new Intent(MainTabActivity.this, ShareGroupActivity.class)));
...
}
}
-
public class ShareGroupActivity extends TabsGroupActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startChildActivity("ShareActivity", new Intent(this, ShareActivity.class));
}
}
-
public class ShareActivity extends BaseActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.share);
testFacebookConnection();
}
public void testFacebookConnection(){
Session session = new Session(this);
Session.setActiveSession(session);
SessionState state = session.getState();
Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);
Session.StatusCallback statusCallback =
new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
Toast.makeText(ShareActivity.this, "Facebook session status changed", Toast.LENGTH_SHORT).show();
}
};
if (!session.isOpened() && !session.isClosed() && session.getState() != SessionState.OPENING) {
OpenRequest open = new OpenRequest(this).setCallback(statusCallback);
List<String> permission = new ArrayList<String>();
permission.add("publish_actions");
open.setPermissions(permission);
session.openForPublish(open);
} else {
Session.openActiveSession(this, true, statusCallback);
}
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Session.getActiveSession().onActivityResult(this, requestCode, resultCode, data);
}
}
keine Ahnung, wie es zu lösen?
Update 1 Stack-Trace:
FATAL EXCEPTION: main java.lang.RuntimeException: Unable to resume activity {dk.imu.konnekt/com.facebook.LoginActivity}: com.facebook.FacebookException: Cannot call LoginActivity with a null calling package. This can occur if the launchMode of the caller is singleInstance. at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2812) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2851) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2234) at android.app.ActivityThread.access$600(ActivityThread.java:139) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261) at android.os.Handler.dispatchMessage(Handler.java:99) android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:4945) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: com.facebook.FacebookException: Cannot call LoginActivity with a null calling package. This can occur if the launchMode of the caller is singleInstance. at com.facebook.LoginActivity.onResume(LoginActivity.java:110) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1236) at android.app.Activity.performResume(Activity.java:4613) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2796) ... 12 more
Update 2: Ich sah den Code durch und die Umsetzung von startChildActivity gefunden:
public void startChildActivity(String Id, Intent intent) {
Window window = getLocalActivityManager().startActivity(Id,intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
mIdList.add(Id);
setContentView(window.getDecorView());
}
}
Es verwendet die Flagge FLAG_ACTIVITY_CLEAR_TOP. Ich habe versucht, es zu entfernen, aber keine Veränderung im Ergebnis.
Update 3:
Der Facebook-Code verwendet
callingPackage = getCallingPackage();
und
if (callingPackage == null) {
throw new FacebookException(NULL_CALLING_PKG_ERROR_MSG);
}
http://developer.android.com/reference/android/app/Activity.html#getCallingPackage()
Diese Methode hat eine Notiz:
If the calling activity is not expecting a result (that is it did not use the startActivityForResult(Intent, int) form that includes a request code), then the calling package will be null.
Bei dem Verfahren startChildActivity ich die getLocalActivityManager() verwenden startActivity, in TabsGroupActivity die Activity erstreckt, Registerkarte Aktivitäten zu behandeln.. http://developer.android.com/reference/android/app/LocalActivityManager.html#startActivity(java.lang.String, android.content.Intent)
Diese Methode sagt nicht, was die Notizen sagen. Es erwartet kein Ergebnis und verwendet nicht die startActivityForResult-Methode. Die Methode gewährleistet auch etwas Ähnliches wie der Launchmode singleinstance. Wie soll ich diese Methode Implementierung ändern, so kann es mit Facebook arbeiten?
'die launchMode des Anrufers ist singleInstance' – njzk2
Post voll stacktrace – njzk2
jede SingleInstance Aktivität in das alles? – njzk2