Allowing OtherApps to Start Your Activity

为了开发更多人使用的App,我们总希望我们的App能够提供一种接口被其他App调用。如我们常见的 大众点评  与  豆瓣。他们这种资源丰富的App能给我们提供很多丰富的资源。

例如豆瓣的scheme:

              <activity
android:name="com.douban.movie.PlayVideoActivity"
>
<intent-filter>
<action
android:name="com.douban.movie"
>
</action>
<action
android:name="android.intent.action.VIEW"
>
</action>
<category
android:name="android.intent.category.DEFAULT"
>
</category>
<category
android:name="android.intent.category.BROWSABLE"
>
</category>
<data
android:scheme="http"
android:host="movie.douban.com"
android:pathPattern="/trailer/.*/"
>
</data>
</intent-filter>
</activity>

主要的是在于定义了:

android:name="android.intent.category.BROWSABLE"

<data
android:scheme="http"
android:host="movie.douban.com"
android:pathPattern="/trailer/.*/"
>
</data>

我们知道,如果用户的手机上没有安装您的App,第三方App如果需要使用Scheme跳转的话就会产生错误。

这个样子的话我们的一般解决办法是直接跳转到网页版的应用上去。

所以,将Scheme写成类似Url的形式方便我们进行应用内的跳转与网页上的跳转。

当然,也可以分开来写,如同大众点评的。

 String id = "3102397";
try
{
Uri url = Uri.parse("dianping://shopinfo?id=" + id);
Intent intent = new Intent(Intent.ACTION_VIEW, url);
mContext.startActivity(intent);
}
catch (Exception e)
{
// 没有安装应用,默认打开HTML5站
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://m.dianping.com/shop/" + id));
mContext.startActivity(intent);
}

附件中上传了一个自己写的sheme的demo如果不清楚的可以看看

demo

移动开发中的Scheme跳转说明——Allowing OtherApps to Start Your Activity的更多相关文章

  1. WEB开发中的页面跳转方法总结

    PHP header()函数跳转 PHP的header()函数非常强大,其中在页面url跳转方面也调用简单,使用header()直接跳转到指定url页面,这时页面跳转是302重定向: $url = & ...

  2. php开发中的页面跳转方法总结

    PHP页面跳转实现的功能就是将网站中一个网页跳转到另一个网页中.对于刚刚学习PHP语言的朋友来说,是必须要掌握的基础方法. 页面跳转可能是由于用户单击链接.按钮等触发的,也可能是系统自动产生的.页面自 ...

  3. Android开发中使用Intent跳转到系统应用中的拨号界面、联系人界面、短信界面

    现在开发中的功能需要直接跳转到拨号.联系人.短信界面等等,查找了很多资料,自己整理了一下. 首先,我们先看拨号界面,代码如下: Intent intent =new Intent(); intent. ...

  4. 新手学习PHP的避雷针,这些坑在PHP开发中就别跳了

    不要!用记事本编辑php文件 早些年能用记事本编程是一些人自我吹嘘的资本,能用记事本编程就是牛逼的代名词.但是这里要告诫大家的是,千万不要使用Windows自带的记事本编辑任何文本文件.用Window ...

  5. Web开发中的服务器跳转与客户端跳转

    两者比较如下: 跳转类型  客户端请求次数 服务端响应次数 URL变化 站外跳转 作用域 服务器跳转 1 1 无 否 pageContext.request.session.application 客 ...

  6. iOS开发中,应用内直接跳转到Appstore

    iOS开发中,应用内直接跳转到Appstore 1.进入appstore中指定的应用NSString *str = [NSString stringWithFormat:                ...

  7. iPhone开发中从一个视图跳到另一个视图有三种方法:

    iPhone开发中从一个视图跳到另一个视图有三种方法:   1.self.view addSubView:view .self.window addSubView,需要注意的是,这个方法只是把页面加在 ...

  8. iPhone开发中,关于视图跳转的总结(转)

    iPhone开发中,关于视图跳转的总结 iPhone开发中从一个视图跳到另一个视图有三种方法: 1. self.view addSubView:view .self.window addSubView ...

  9. IOS程序开发中-跳转到 发送短信界面 实现发短信

    前言:我发现我标题取的不好,谁帮我取个承接上下文的标题?评论一下,我改 项目需求:在程序开发中,我们需要在某个程序里面发送一些短信验证(不是接收短信验证,关于短信验证,传送门:http://www.c ...

随机推荐

  1. Mac中使用svn进行项目管理

    Mac中使用svn进行项目管理,借鉴了http://blog.csdn.net/q199109106q/article/details/8655204 下面方案多人亲測可用 转载请注明出处:http: ...

  2. C++11 thread::detach(2)

    原文地址:http://www.cplusplus.com/reference/thread/thread/detach/ public member function <thread> ...

  3. PopupWindow的使用以及ArrayAdatper.notifyDataSetChanged()无效详解

    Android的对话框有两种:PopupWindow和AlertDialog.它们的不同点在于: AlertDialog的位置固定,而PopupWindow的位置可以随意 AlertDialog是非阻 ...

  4. GlusterFS常用命令

    1.启动/关闭/查看glusterd服务 # /etc/init.d/glusterd start # /etc/init.d/glusterd stop # /etc/init.d/glusterd ...

  5. iOS开发中关于本地数据中SQLite数据库常用的SQL语句

    创建表 CREATE TABLE IF NOT EXISTS "student" ("number" INTEGER PRIMARY KEY AUTOINCRE ...

  6. 17-UIKit(UIView的动画)

    2. UIView的动画 UIView类本身具有动画的功能 2.1 概念 由UI对底层Core Animation框架的封装 可以轻松简单的实现动画效果 2.2 两种使用方式 1> Block ...

  7. JVM调优总结(七)-典型配置举例1

    以下配置主要针对分代垃圾回收算法而言. 堆大小设置 年轻代的设置很关键 JVM中最大堆大小有三方面限制:相关操作系统的数据模型(32-bt还是64-bit)限制:系统的可用虚拟内存限制:系统的可用物理 ...

  8. GitLab 之 Linux十分钟快装

    原文链接:http://www.cnblogs.com/highsea90/p/5191340.html 先把 Shell 命令贴出来,楼主以 CentOS release 6.5 (Final) 6 ...

  9. Resist the Temptation of the Singleton Pattern

    Resist the Temptation of the Singleton Pattern Sam Saariste THE SiNGLETON PATTERN SOLVES MANY OF YOU ...

  10. 新发现的Cyberduck(映射网盘)和zsuncloud(硬件产品很新潮),群辉nas的确好用(购买链接)

    https://cyberduck.io/?l=en http://www.zsuncloud.com/ 群辉nas的确好用啊在哪里可以买到?官网 淘宝也可以自己做黑群晖 先用xpenoboot is ...