Android 从其他应用程序启动facebook应用程序

Android 从其他应用程序启动facebook应用程序,android,Android,如何从android中的应用程序启动facebook应用程序?要启动默认启动程序活动: Intent intent = new Intent("android.intent.category.LAUNCHER"); intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity"); startActivity(intent); 我做了一些研究,因为我想找到答案:)。我找到了一些方法来轻松地开始不同的活

如何从android中的应用程序启动facebook应用程序?

要启动默认启动程序活动:

Intent intent = new Intent("android.intent.category.LAUNCHER");
intent.setClassName("com.facebook.katana", "com.facebook.katana.LoginActivity");
startActivity(intent);
我做了一些研究,因为我想找到答案:)。我找到了一些方法来轻松地开始不同的活动。但我不能保证这在facebook升级后会起作用。我用我目前的facebook应用程序测试了它,它运行正常。至少我使用“am start…”用“adb shell”对它进行了测试

基本原则是:

String uri = "facebook://facebook.com/inbox";
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
startActivity(intent);
未选中facebook.com部分。您甚至可以键入:facebook://gugus.com/inbox“具有相同的效果

如何在亚洲开发银行做到这一点

1. Start adb shell through console: "adb shell"
2. run: "am start -a android.intent.action.VIEW -d facebook://facebook.com/inbox"
这将启动收件箱活动。 下面是一些URI和示例。我认为他们所做的一切都是他们自己说的

facebook://facebook.com/inbox
facebook://facebook.com/info?user=544410940     (id of the user. "patrick.boos" won't work)
facebook://facebook.com/wall
facebook://facebook.com/wall?user=544410940   (will only show the info if you have added it as friend. otherwise redirects to another activity)
facebook://facebook.com/notifications
facebook://facebook.com/photos
facebook://facebook.com/album
facebook://facebook.com/photo
facebook://facebook.com/newsfeed
您可以为某些URI提供额外的参数,但我没有时间浏览这些活动的所有代码


我是怎么做到的?查看apktool。

从android应用程序启动另一个应用程序,只有在您启动的意图操作与您要启动的其他应用程序的意图过滤器匹配时才能完成

正如@patrick演示的,将facebook.apk下载到emulator,并尝试通过adb shell命令运行它。它很好用


将意图过滤器和数据作为Uri传递查看最新的Facebook apk(1.6),看起来“Facebook://”和“fb://”都是注册协议

facebook://

facebook:/chat
facebook:/events
facebook:/friends
facebook:/inbox
facebook:/info
facebook:/newsfeed
facebook:/places
facebook:/requests
facebook:/wall
fb://

对不起,如果我错过了一些。。。在emulator中只玩其中一小部分,看看它们是否真的能工作——其中一部分会导致Facebook应用程序崩溃


其中postid采用
uid\u postid
格式,例如
11204705797\u 10100412949637447
如果任何人想要直接打开照片

public Intent getOpenFacebookIntent(String pId) {
    try {
        activity.getPackageManager().getPackageInfo("com.facebook.katana", 0);
        return new Intent(Intent.ACTION_VIEW, Uri.parse("facebook:/photos?album=0&photo=" + pId + "&user=" + ownerId));
    } catch (Exception e) {
        return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/"));
    }
}

startActivity(getOpenFacebookIntent(pid));
其中,
ownerId
是上传此图片的用户的Facebook
id
,而
pid
PhotoId

享受:))


这将直接打开facebook群组,其id为:14531755***6215在fb应用程序内部

您是否只想启动该应用程序或某项活动?看起来这已经不起作用了(而且它肯定已经习惯了!)。facebook://facebook.com/wall?user=1230123 只打开Facebook到流活动,而不是指定用户的墙。弄明白了,请参阅下面我关于新协议的帖子。你好,帕特里克:这里它打开了已安装的Facebook应用程序,但是我需要打开facebook应用程序,同时打开更新状态以及附加到状态的图像,如何实现这一点。。。?非常感谢您的帮助……对不起。。我猜那是旧版本的。查看@NPike的帖子。这些可能是您需要的:)如果应用程序未安装会发生什么?是否有文档记录?我试图搜索它,但在任何地方都找不到。所以有可能有一天这也会破坏我们的应用程序,不是吗?@AndersMetnik看到我直接打开照片的答案。我怎样才能打开一个群组?我尝试过,但没有成功fb://groups/{groupu_id}这在任何地方都有记录吗?我想详细了解一下。很抱歉,它似乎不适用于Facebook更新25.0.0.19.30。它不适用于我。这里有一个单独的问题,这个答案被引用了(),它对其他人也不起作用。那一次它起作用了。facebook应用程序iteself有很多变化。也许现在不行了。对此表示歉意。
public Intent getOpenFacebookIntent(String pId) {
    try {
        activity.getPackageManager().getPackageInfo("com.facebook.katana", 0);
        return new Intent(Intent.ACTION_VIEW, Uri.parse("facebook:/photos?album=0&photo=" + pId + "&user=" + ownerId));
    } catch (Exception e) {
        return new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/"));
    }
}

startActivity(getOpenFacebookIntent(pid));
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.facebook.com/groups/14531755***6215/")));