要与特定的Facebook好友打开Facebook应用,您可以使用此意图:
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("fb://profile/%s", friendId)));
LinkedIn的类似解决方案:
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("linkedin://profile/%s", friendId)));
我认为下一个适用于Google Plus(没有测试,但看起来很有希望):
final Intent intent =new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("https://plus.google.com/%s/posts", friendId)));
我试图找到如何使用此类意图打开VKontakte(VK)社交网络应用程序,但找不到它。
有这样的意图吗?如果是这样,它是什么?
答案 0 :(得分:4)
接下来是开发人员的答案:
是的,它以同样的方式完成:
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("vkontakte://profile/%d", friendId)));
如果您需要打开社区,请使用相同的网址,但将减号添加到社区ID。
答案 1 :(得分:3)
以下是我在VK应用清单中找到的网址列表
注意:删除http / https后的空格。所以我不会发布超过2个链接 你可以使用其中任何一个从你的应用程序启动vk
这是我怎么做的
private void sendIntentToVkApp() {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://vk.com/hmrussia"));
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
这里是VK Manifest的一部分,其中定义了所有方案
<intent-filter>
<category
android:name="android.intent.category.DEFAULT"/>
<action
android:name="android.intent.action.VIEW"/>
<data
android:scheme="vklink"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="http"
android:host="vk.com"
android:pathPattern="/.*"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="http"
android:host="vkontakte.ru"
android:pathPattern="/.*"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="https"
android:host="vk.com"
android:pathPattern="/.*"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="https"
android:host="vkontakte.ru"
android:pathPattern="/.*"/>
</intent-filter>
<intent-filter>
<action
android:name="android.intent.action.VIEW"/>
<category
android:name="android.intent.category.DEFAULT"/>
<category
android:name="android.intent.category.BROWSABLE"/>
<data
android:scheme="vkontakte"
android:pathPattern="/.*"/>
</intent-filter>