0

Сan we open the facebook link so that the menu selection of applications for viewing the content was still and facebook browsers? The standard startup

fun openLink(link: String) {
    Intent(Intent.ACTION_VIEW).apply {
        flags = Intent.FLAG_ACTIVITY_NEW_TASK
        data = Uri.parse(link)

        context.startActivity( this)
    }
 }

opens only browsers, and some browsers, such as chrome and edge, run another one, where then appears facebook (if it is installed), the only thing I was able to find was to open the links directly to facebook, if it is installed, without the possibility of choosing an application to open the link

Intent(Intent.ACTION_VIEW).apply {
            flags = Intent.FLAG_ACTIVITY_NEW_TASK
            try {
                val applicationInfo: ApplicationInfo = 
                       packageManager.getApplicationInfo("com.facebook.katana", 0)
                if (applicationInfo.enabled) {
                    // http://stackoverflow.com/a/24547437/1048340
                    data = Uri.parse("fb://facewebmodal/f?href=https://facebook.com/")
                }
            } catch (ignored: PackageManager.NameNotFoundException) {
                data = Uri.parse("https://facebook.com/")
            }

            startActivity(this)
        }
  1. what i have
  2. what i want and what chorme send after open facebook link

1 Answers1

0

are you familiar with EXTRA_INITIAL_INTENTS? create two separate Intents (if fb app present and enabled) and join them

Intent chooserIntent = Intent.createChooser(browserIntent, "Open in...");
if (fbIntent != null) {
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { fbIntent });
}
startActivity(chooserIntent);

some more info in HERE and HERE

snachmsm
  • 17,866
  • 3
  • 32
  • 74