Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen built-in browser through intent and PackageManager
    primarykey
    data
    text
    <p>I want to know if I can open a share page in the browser instead of the Facebook app. If the Facebook app is present then share something by opening the Facebook app. Otherwise if it is not installed share the thing by opening the browser. I am using the following Stack Overflow question for guidance: <a href="https://stackoverflow.com/questions/3515198/share-text-on-facebook-from-android-app-via-action-send">Share Text on Facebook from Android App via ACTION_SEND</a>.</p> <pre><code>sharingIntent.setType("text/plain"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "http://www.some-link-to-open.com"); PackageManager pm = getPackageManager(); List&lt;ResolveInfo&gt; activityList = pm.queryIntentActivities(sharingIntent, 0); for (final ResolveInfo app : activityList) { if ((app.activityInfo.name).contains("facebook")) { /** * Open Facebook app */ final ActivityInfo activity = app.activityInfo; final ComponentName name = new ComponentName( activity.applicationInfo.packageName, activity.name); sharingIntent.addCategory(Intent.CATEGORY_LAUNCHER); sharingIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); sharingIntent.setComponent(name); startActivity(sharingIntent); break; } else if ((app.activityInfo.name).contains("internet")) { /** * Open Facebook in the browser. */ Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse("https://m.facebook.com/sharer.php?u=" + "http://www.some-link-to-open.com")); startActivity(i); } </code></pre> <p>For determining the Facebook app, we use:</p> <pre><code>(app.activityInfo.name).contains("facebook") </code></pre> <p>So in the above code I want to know in the</p> <pre><code>else if ((app.activityInfo.name).contains("internet")) </code></pre> <p>what appropriate code you need to enter to determine the browser?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload