我想使用Message Dialog使用我的应用程序向我的Facebook朋友发送消息,但它仅对Message Dialog失败并且对于共享消息工作正常。 我得到一个错误,没有安装Facebook应用程序。但我已经安装了最新的Facebook应用程序。 请帮忙。
public class MessageFBFriends extends FragmentActivity {
private UiLifecycleHelper uiHelper;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
uiHelper = new UiLifecycleHelper(this,null);
uiHelper.onCreate(savedInstanceState);
// if (FacebookDialog.canPresentMessageDialog(getApplicationContext(),
// FacebookDialog.MessageDialogFeature.MESSAGE_DIALOG))
{
FacebookDialog messageDialog = new FacebookDialog.MessageDialogBuilder(this).build();
uiHelper.trackPendingDialogCall(messageDialog.present());
}
/* if (FacebookDialog.canPresentShareDialog(getApplicationContext(),
FacebookDialog.ShareDialogFeature.SHARE_DIALOG)) {
FacebookDialog shareDialog = new FacebookDialog.ShareDialogBuilder(this).build();
// .setLink("https://developers.facebook.com/android").build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}
else{
String linkString = "https://developers.facebook.com/android";
String sharerUrl = "https://www.facebook.com/sharer/sharer.php?u=" + linkString;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(sharerUrl));
this.startActivity(intent);
}*/
}
@Override
protected void onStart() {
super.onStart();
// Update the display every time we are started.
// displaySelectedFriends(RESULT_OK);
}
@Override
protected void onResume() {
super.onResume();
// Call the 'activateApp' method to log an app event for use in analytics and advertising reporting. Do so in
// the onResume methods of the primary Activities that an app may be launched into.
uiHelper.onResume();
}
@Override
protected void onPause() {
super.onPause();
// Call the 'deactivateApp' method to log an app event for use in analytics and advertising
// reporting. Do so in the onPause methods of the primary Activities that an app may be launched into.
uiHelper.onPause();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
uiHelper.onActivityResult(requestCode, resultCode, data, new FacebookDialog.Callback() {
@Override
public void onError(FacebookDialog.PendingCall pendingCall, Exception error, Bundle data) {
Log.e("Activity", String.format("Error: %s", error.toString()));
}
@Override
public void onComplete(FacebookDialog.PendingCall pendingCall, Bundle data) {
Log.i("Activity", "Success!");
}
});
}
}
01-31 14:11:09.581: E/test(14362): Exception
01-31 14:11:09.591: E/AndroidRuntime(14362): FATAL EXCEPTION: main
01-31 14:11:09.591: E/AndroidRuntime(14362): Process: com.example.androidjsonlistview, PID: 14362
01-31 14:11:09.591: E/AndroidRuntime(14362): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidjsonlistview/com.fest.frontend.MessageFBFriends}: com.facebook.FacebookException: Unable to create Intent; this likely means the Facebook app is not installed.
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.ActivityThread.access$800(ActivityThread.java:145)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1243)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.os.Handler.dispatchMessage(Handler.java:102)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.os.Looper.loop(Looper.java:136)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.ActivityThread.main(ActivityThread.java:5136)
01-31 14:11:09.591: E/AndroidRuntime(14362): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 14:11:09.591: E/AndroidRuntime(14362): at java.lang.reflect.Method.invoke(Method.java:515)
01-31 14:11:09.591: E/AndroidRuntime(14362): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:819)
01-31 14:11:09.591: E/AndroidRuntime(14362): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:635)
01-31 14:11:09.591: E/AndroidRuntime(14362): at dalvik.system.NativeStart.main(Native Method)
01-31 14:11:09.591: E/AndroidRuntime(14362): Caused by: com.facebook.FacebookException: Unable to create Intent; this likely means the Facebook app is not installed.
01-31 14:11:09.591: E/AndroidRuntime(14362): at com.facebook.widget.FacebookDialog$Builder.build(FacebookDialog.java:670)
01-31 14:11:09.591: E/AndroidRuntime(14362): at com.fest.frontend.MessageFBFriends.onCreate(MessageFBFriends.java:43)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.Activity.performCreate(Activity.java:5231)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
01-31 14:11:09.591: E/AndroidRuntime(14362): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
01-31 14:11:09.591: E/AndroidRuntime(14362): ... 11 more