How To Open Vkontakte App With A Specific Friend?
Background In order to open Facebook app with a specific Facebook friend, you can use this intent: final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format('fb:
Solution 1:
The answer from developer is next:
Yes, it's done the same way:
finalIntentintent=newIntent(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.
Solution 2:
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
privatevoidsendIntentToVkApp() {
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><categoryandroid:name="android.intent.category.DEFAULT"/><actionandroid:name="android.intent.action.VIEW"/><dataandroid:scheme="vklink"/></intent-filter><intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:scheme="http"android:host="vk.com"android:pathPattern="/.*"/></intent-filter><intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:scheme="http"android:host="vkontakte.ru"android:pathPattern="/.*"/></intent-filter><intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:scheme="https"android:host="vk.com"android:pathPattern="/.*"/></intent-filter><intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:scheme="https"android:host="vkontakte.ru"android:pathPattern="/.*"/></intent-filter><intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:scheme="vkontakte"android:pathPattern="/.*"/></intent-filter>
Solution 3:
In Kotlin. This will open the app if installed, otherwise the browser will open.
privatefunopenVk(profileId: String) {
val uri = Uri.parse("http://vk.com/$profileId")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
Post a Comment for "How To Open Vkontakte App With A Specific Friend?"