读书人

搬动开发中的Scheme跳转说明Allow

发布时间: 2013-09-07 14:12:45 作者: rapoo

移动开发中的Scheme跳转说明——Allowing OtherApps to Start Your Activity

Allowing OtherApps to Start Your Activity

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

例如豆瓣的scheme:

 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

读书人网 >其他相关

热点推荐