How to open VK application with a specific friend?

Background

To open the Facebook application with your Facebook friend, you can use this intention:

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

A similar solution found for LinkedIn:

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

I think the following will work for Google Plus (have not tested it, but it seems promising):

final Intent intent =new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("https://plus.google.com/%s/posts", friendId)));

Question

I tried to find how to open the VKontakte (VK) social network application using such intentions, but could not find it.

Is there such an intention? If so, what is it?

+4
source share
2 answers

Further the answer from the developer:

Yes, it was 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 a minus sign in the community identifier.

+4

url, VK app

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

. http/https. SO 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,

<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>
+3

All Articles