Opening/starting a specific Android activity passing an intent parameter from the browser
up vote
0
down vote
favorite
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. Please see my scenario below.
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
android android-intent kotlin
add a comment |
up vote
0
down vote
favorite
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. Please see my scenario below.
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
android android-intent kotlin
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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. Please see my scenario below.
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
android android-intent kotlin
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. Please see my scenario below.
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
android android-intent kotlin
android android-intent kotlin
edited Nov 10 at 18:41
asked Nov 10 at 16:55
Wai Yan Hein
2,32043691
2,32043691
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
You have 4 options to achieve what you want:
- Deep Links
- Android App Links
- Firebase Dynamic Links
- Firebase App Indexing
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 pattern URL
s and pass the desired parameters as URL
query params.
AndroidManifest.xml
<activity android:name=".SphereViewerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "myapp://zxing" -->
<data android:host="zxing" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
SphereViewerActivity.kt
class SphereViewerActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sphere_viewer)
if (intent != null && intent.action == Intent.ACTION_VIEW) {
intent.data?.apply{
if (getQueryParameter("image_url") != null && getQueryParameter("image_url").isNotEmpty()) {
val imageUrl = data.getQueryParameter ("image_url") as String
// do what you want to do with imageUrl
}
}
}
}
}
Your html snippet:
<a href="myapp://zxing?image_url=some_image_url"> Take a QR code </a>
I tried adding app links. Even if I set up with the right details and test the link with the right details, not working. Please, check the question edited please?
– Wai Yan Hein
Nov 10 at 18:42
Ok, your issue is able to solve with simple deep link. I've updated the answer.
– aminography
Nov 10 at 18:49
@WaiYanHein: Did you test it?
– aminography
Nov 10 at 20:13
Man. Thanks so much, That worked,
– Wai Yan Hein
Nov 10 at 20:14
You're welcome dude :)
– aminography
Nov 10 at 20:15
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
You have 4 options to achieve what you want:
- Deep Links
- Android App Links
- Firebase Dynamic Links
- Firebase App Indexing
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 pattern URL
s and pass the desired parameters as URL
query params.
AndroidManifest.xml
<activity android:name=".SphereViewerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "myapp://zxing" -->
<data android:host="zxing" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
SphereViewerActivity.kt
class SphereViewerActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sphere_viewer)
if (intent != null && intent.action == Intent.ACTION_VIEW) {
intent.data?.apply{
if (getQueryParameter("image_url") != null && getQueryParameter("image_url").isNotEmpty()) {
val imageUrl = data.getQueryParameter ("image_url") as String
// do what you want to do with imageUrl
}
}
}
}
}
Your html snippet:
<a href="myapp://zxing?image_url=some_image_url"> Take a QR code </a>
I tried adding app links. Even if I set up with the right details and test the link with the right details, not working. Please, check the question edited please?
– Wai Yan Hein
Nov 10 at 18:42
Ok, your issue is able to solve with simple deep link. I've updated the answer.
– aminography
Nov 10 at 18:49
@WaiYanHein: Did you test it?
– aminography
Nov 10 at 20:13
Man. Thanks so much, That worked,
– Wai Yan Hein
Nov 10 at 20:14
You're welcome dude :)
– aminography
Nov 10 at 20:15
add a comment |
up vote
2
down vote
accepted
You have 4 options to achieve what you want:
- Deep Links
- Android App Links
- Firebase Dynamic Links
- Firebase App Indexing
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 pattern URL
s and pass the desired parameters as URL
query params.
AndroidManifest.xml
<activity android:name=".SphereViewerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "myapp://zxing" -->
<data android:host="zxing" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
SphereViewerActivity.kt
class SphereViewerActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sphere_viewer)
if (intent != null && intent.action == Intent.ACTION_VIEW) {
intent.data?.apply{
if (getQueryParameter("image_url") != null && getQueryParameter("image_url").isNotEmpty()) {
val imageUrl = data.getQueryParameter ("image_url") as String
// do what you want to do with imageUrl
}
}
}
}
}
Your html snippet:
<a href="myapp://zxing?image_url=some_image_url"> Take a QR code </a>
I tried adding app links. Even if I set up with the right details and test the link with the right details, not working. Please, check the question edited please?
– Wai Yan Hein
Nov 10 at 18:42
Ok, your issue is able to solve with simple deep link. I've updated the answer.
– aminography
Nov 10 at 18:49
@WaiYanHein: Did you test it?
– aminography
Nov 10 at 20:13
Man. Thanks so much, That worked,
– Wai Yan Hein
Nov 10 at 20:14
You're welcome dude :)
– aminography
Nov 10 at 20:15
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
You have 4 options to achieve what you want:
- Deep Links
- Android App Links
- Firebase Dynamic Links
- Firebase App Indexing
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 pattern URL
s and pass the desired parameters as URL
query params.
AndroidManifest.xml
<activity android:name=".SphereViewerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "myapp://zxing" -->
<data android:host="zxing" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
SphereViewerActivity.kt
class SphereViewerActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sphere_viewer)
if (intent != null && intent.action == Intent.ACTION_VIEW) {
intent.data?.apply{
if (getQueryParameter("image_url") != null && getQueryParameter("image_url").isNotEmpty()) {
val imageUrl = data.getQueryParameter ("image_url") as String
// do what you want to do with imageUrl
}
}
}
}
}
Your html snippet:
<a href="myapp://zxing?image_url=some_image_url"> Take a QR code </a>
You have 4 options to achieve what you want:
- Deep Links
- Android App Links
- Firebase Dynamic Links
- Firebase App Indexing
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 pattern URL
s and pass the desired parameters as URL
query params.
AndroidManifest.xml
<activity android:name=".SphereViewerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "myapp://zxing" -->
<data android:host="zxing" />
<data android:scheme="myapp" />
</intent-filter>
</activity>
SphereViewerActivity.kt
class SphereViewerActivity : AppCompatActivity(){
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sphere_viewer)
if (intent != null && intent.action == Intent.ACTION_VIEW) {
intent.data?.apply{
if (getQueryParameter("image_url") != null && getQueryParameter("image_url").isNotEmpty()) {
val imageUrl = data.getQueryParameter ("image_url") as String
// do what you want to do with imageUrl
}
}
}
}
}
Your html snippet:
<a href="myapp://zxing?image_url=some_image_url"> Take a QR code </a>
edited Nov 10 at 18:57
answered Nov 10 at 18:22
aminography
2,88011127
2,88011127
I tried adding app links. Even if I set up with the right details and test the link with the right details, not working. Please, check the question edited please?
– Wai Yan Hein
Nov 10 at 18:42
Ok, your issue is able to solve with simple deep link. I've updated the answer.
– aminography
Nov 10 at 18:49
@WaiYanHein: Did you test it?
– aminography
Nov 10 at 20:13
Man. Thanks so much, That worked,
– Wai Yan Hein
Nov 10 at 20:14
You're welcome dude :)
– aminography
Nov 10 at 20:15
add a comment |
I tried adding app links. Even if I set up with the right details and test the link with the right details, not working. Please, check the question edited please?
– Wai Yan Hein
Nov 10 at 18:42
Ok, your issue is able to solve with simple deep link. I've updated the answer.
– aminography
Nov 10 at 18:49
@WaiYanHein: Did you test it?
– aminography
Nov 10 at 20:13
Man. Thanks so much, That worked,
– Wai Yan Hein
Nov 10 at 20:14
You're welcome dude :)
– aminography
Nov 10 at 20:15
I tried adding app links. Even if I set up with the right details and test the link with the right details, not working. Please, check the question edited please?
– Wai Yan Hein
Nov 10 at 18:42
I tried adding app links. Even if I set up with the right details and test the link with the right details, not working. Please, check the question edited please?
– Wai Yan Hein
Nov 10 at 18:42
Ok, your issue is able to solve with simple deep link. I've updated the answer.
– aminography
Nov 10 at 18:49
Ok, your issue is able to solve with simple deep link. I've updated the answer.
– aminography
Nov 10 at 18:49
@WaiYanHein: Did you test it?
– aminography
Nov 10 at 20:13
@WaiYanHein: Did you test it?
– aminography
Nov 10 at 20:13
Man. Thanks so much, That worked,
– Wai Yan Hein
Nov 10 at 20:14
Man. Thanks so much, That worked,
– Wai Yan Hein
Nov 10 at 20:14
You're welcome dude :)
– aminography
Nov 10 at 20:15
You're welcome dude :)
– aminography
Nov 10 at 20:15
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241234%2fopening-starting-a-specific-android-activity-passing-an-intent-parameter-from-th%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown