0

how to make in app browser in android studio to open link directly like twitter and instagram.I tried below method which is not giving the desired out come.

 button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(Intent.ACTION_WEB_SEARCH); intent.putExtra(SearchManager.QUERY,url); startActivity(intent); } }); 

1 Answer 1

3

this feature is called Chrome Custom Tabs, check out some tutorial how to implement

for gradle:

implementation 'androidx.browser:browser:1.2.0' 

code implementation:

Uri uri = Uri.parse("www.google.com"); new CustomTabsIntent.Builder().build().launchUrl(context, uri); 
Sign up to request clarification or add additional context in comments.

2 Comments

this only works if a user has chrome available on their device though, right ?
afaik yes, you can detect that with some ActivityNotFoundException implementation (in which dev may open e.g. own Activity with WebView). more info in HERE

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.