How to open VKontakte app with a specific friend?

隐身守侯 提交于 2019-12-03 16:46:06

The answer from developer is next:

Yes, it's done the same way:

final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("vkontakte://profile/%d", friendId)));

If you need to open a community, use the same URL but add the minus sign to the community ID.

Question answered here

Here is a list of url i found at VK app manifest

  • http ://vk.com/.*
  • http ://vkontakte.ru/.*
  • https ://vk.com/.*
  • https ://vkontakte.ru/.*
  • http ://m.vk.com/.*

Note: remove space after http/https. SO won't let me post more than 2 links you can use any of that to launch vk from your app

here is how i do that

 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();
    }
}

and here is a part of VK Manifest where all the schemes are defined

<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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!