I am developing an Android application and a website. What I am trying to do now is that I like to open the specific activity of Android application from the browser when the user click on a link.
This is my Android activity class
class SphereViewerActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sphere_viewer)
intent.getStringExtra("image_url")
}
}
As you can see in my code, I am getting the image_url parameter from the browser. Is it possible to open that activity passing the parameter from the JavaScript or browser?
I found the solution, it is to have the link like this
<a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;S.browser_fallback_url=http%3A%2F%2Fzxing.org;end"> Take a QR code </a>
But how can I pass intent data as parameter?
I tried adding the app links. not working when I click Test App Links
You have 4 options to achieve what you want:
Refer to this post to see more descriptions about them.
In simplest approach (Deep Links), you can introduce your
Activity
as a handler of specific patternURL
s and pass the desired parameters asURL
query params.AndroidManifest.xml
SphereViewerActivity.kt
Your html snippet: