---
title: "android通过自定义schame和host来启动app"
author: "hellorheaven"
date: "2014-08-15T15:02:12Z"
tags: []
categories: ["移动开发"]
slug: "android-schame-host-app"
draft: false
lastmod: "2014-08-15T15:02:12Z"
id: 2104361
url: "https://hellorheaven.iteye.com/blog/2104361"
---

很多时候，我们可以看到在web页面中点击链接，可以直接启动app。

原理很简单，通过访问指定的文件，请求链接"abc://def"，搜索到对应的app，启动...（当然，手机需要已安装该app）

app的manifest文件启动activity里边加上


```java

            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                    android:host="def"
                    android:scheme="abc" />
            </intent-filter>

```


即可