最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to open android application from a webpage? - Stack Overflow

programmeradmin3浏览0评论

can I call my app from HTML?

for example:I can call webpage with this code correctly from my app.

android code:

  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                                    "myDomain")));

and after doing something in my site, I want to open my android app again.

I find this code,

<a href="market://details?id=info.androidhive.slidingmenu">

but it's just call Market to find and install the app!

can I call my app from HTML?

for example:I can call webpage with this code correctly from my app.

android code:

  startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                                    "myDomain.")));

and after doing something in my site, I want to open my android app again.

I find this code,

<a href="market://details?id=info.androidhive.slidingmenu">

but it's just call Market to find and install the app!

Share Improve this question edited Jul 14, 2015 at 11:27 Gopal Singh Sirvi 4,6495 gold badges38 silver badges56 bronze badges asked Jul 14, 2015 at 10:41 user1794863user1794863 1812 gold badges4 silver badges10 bronze badges 1
  • Wouldn't Android's 'Back' button let the user go back to your app? If you want more control, you can always let the user browse the webpage inside Android's WebView inside your app. In that case, going back can be achieved by finishing the WebView activity. I cannot ment on iOS though. – alexan Commented Jul 14, 2015 at 10:59
Add a ment  | 

4 Answers 4

Reset to default 10

You might have a look at this: https://developer.android./training/app-indexing/deep-linking.html

<activity
android:name=".example.android.GizmosActivity"
android:label="@string/title_gizmos" >
<intent-filter android:label="@string/filter_title_viewgizmos">
    <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 "http://www.example./gizmos” -->
    <data android:scheme="http"
          android:host="www.example."
          android:pathPrefix="/gizmos" />
    <!-- note that the leading "/" is required for pathPrefix-->
    <!-- Accepts URIs that begin with "example://gizmos”
    <data android:scheme="example"
          android:host="gizmos" />
    -->
</intent-filter>

So your app will be started by this link:

<a href="example://gizmos">

for iOS you can set URLSchemes that will launch the app if typed on the browser: that is for example if your app called market

market:// will launch the app

to add the URLScheme do it in the info tab :

you can handle the url options by implementing application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods.

It is no longer possible starts to Android Chrome 25 link

For iOS you can read this question

You can achieve it by adding a small script in website and some changes in code. You have to make url schemes.

发布评论

评论列表(0)

  1. 暂无评论