Link on a webpage to open instagram app
You have a typo the href should be ://
not //:
<div>
<a href="instagram://media?id=434784289393782000_15903882">instagram://media?id=434784289393782000_15903882</a>
How do I make a link open an Instagram page in an app installed on flutter
you can use url_launcher package and following approach
if (await canLaunch(url)) {
await launch(
'https://www.instagram.com/<INSTAGRAM_PROFILE>/',
universalLinksOnly: true,
);
}
Intent to open Instagram user profile on Android
I solved this problem using the following code.
Uri uri = Uri.parse("http://instagram.com/_u/xxx");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);
likeIng.setPackage("com.instagram.android");
try {
startActivity(likeIng);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/xxx")));
}
how to make links from my website to direct to my app if installed
I found that the way to do this, was using the App Links assistant, which you can find in android studio under Tools -> App Links assistant. This is what you should see on the side once you open it:
Step 1
Click "Open URL Mapping Editor", then add a URL mapping (Click the "+").
In the host, put your website link e.g: https://www.example.com. For Path, in the select box, select just "path" and put nothing in the type box.
Step 2
The Select Activity button does not work for Kotlin, so here's the code that you manually need to put in.
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent) {
val wbWebView = findViewById<View>(R.id.your_webview) as WebView
val appLinkAction = intent.action
val appLinkData = intent.data
if (Intent.ACTION_VIEW == appLinkAction && appLinkData != null) {
wbWebView.loadUrl(appLinkData.toString())
} else {
// default link that it goes to when opening app
wbWebView.loadUrl("https://www.example.com")
}
}
and in your onCreate add handleIntent(intent)
Step 3
Click the "Open Digital Asset Links File Generator". Most of the information will be already filled, so you can go on to click the "Generate Digital Asset Links File". Make a folder called ".well-known" in your website and then put a file in there called "assetlinks.json", paste the preview into there. So when you go to https://www.yourwebsite.com/.well-known/assetlinks.json you should be able to see the Digital asset links file. You can also see other websites Digital asset links file. Like for google, https://www.google.com/.well-known/assetlinks.json.
Then proceed to click the "Link and Verify" button, If all goes well you should see this appear beneath the button:
Step 4
Time to test! Go ahead and click on "Test app links" and put in a URL from your website. If all goes well, you shouldn't see a disambiguation dialogue.
I also like to do further testing by sending myself an email with the link in it.
Notes
You can only use the App Links Assistant if your website is using https instead of http.
I added android:launchMode="singleTask"
into my activity tag in the manifest, this means that If you click on a link from your website in an email then it will open in a new window.
They have a doc about this here which includes a video (Keep in mind that they are using java)
Related Topics
Cannot Keep Android Service Alive After App Is Closed
Android Volley - Basicnetwork.Performrequest: Unexpected Response Code 400
Making Voice Calls from Android Phone Connected to Linux
How to Delete Shared Preferences Data from App in Android
Retrofit @Body With @Multipart Having Issue
Videoview to Match Parent Height and Keep Aspect Ratio
Failure Install Parse Failed Manifest Malformed
Android Prevent Back Button from Closing the App
Html File Input in Android Webview (Android 4.4, Kitkat)
You Need to Use a Theme.Appcompat Theme (Or Descendant) With This Activity
How to Measure Distance to Object With Camera
Waiting Till the Async Task Finish Its Work
How to Dismiss Notification After Action Has Been Clicked
How to Select a Video from the Gallery and Get It's Real Path
How to Display Date Picker for Android With Only Month and Year Fields
How to Get Data from Edit Text in a Recyclerview