我在 Facebook 上发布数据的功能有问题:
public void postData() {
try {
Intent i = new Intent(Intent.ACTION_SEND);
i.setClassName("com.facebook.katana",
"com.facebook.katana.ShareLinkActivity");
i.setType("text/*");
i.putExtra(android.content.Intent.EXTRA_TEXT, "http://sample_url.com");
startActivity(i);
} catch (Exception e) {
Intent i= new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("http://sample_url.com));
startActivity(i);
}
}
每次我获得活动 com.facebook.katana.ShareLinkActivity 无法运行的信息时,我都应该将代码添加到 Android 清单中。Facebook 应用程序安装在手机上。
在 AndroidManifest.xml 中:
<activity android:name="com.facebook.katana.ShareLinkActivity" >
</activity>
LogCat 中的异常:
01-30 14:46:00.903: E/AndroidRuntime(11626): FATAL EXCEPTION: main
01-30 14:46:00.903: E/AndroidRuntime(11626): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.facebook.katana/com.facebook.katana.ShareLinkActivity}; have you declared this activity in your AndroidManifest.xml?
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1634)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1510)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Activity.startActivityFromChild(Activity.java:3531)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Activity.startActivityForResult(Activity.java:3283)
01-30 14:46:00.903: E/AndroidRuntime(11626): at android.app.Activity.startActivity(Activity.java:3370)