Intent intent = new Intent(this, xxx.class); startActivity(intent);
Intent intent = new Intent("this is an action"); startActivity(intent);
如上代码我们只是简单的配置了一个android:scheme属性,那要打开这个Activity也是so easy的
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("azhon.scheme://")));当然< data/>中还可以配置更多的属性(截取自官方中文文档,可以点击上面的manifest / data 配置)
:// : [ | | ]
scheme开头 :// 主机名 : 端口号 / [路径/参数] 路径后面拼接参数也是可以的下面会用到。
这个地址和我们经常使用的网页地址差不多是一样滴
eg:https://loaclhost:8080/index.jsp
在主页面布局添加一个WebView控件,并让它加载assets文件夹中的html文件 布局文件代码:
assets文件夹中的Html代码:
跳转至TestOneActivity
跳转至TestTwoActivity
效果图:
在跳转过去的页面接收传递过来的参数在网页中只需要使用一个超链接便可以轻松的跳转至我们的app,是不是很开心。
当你将这个html文件使用手机的浏览器查看时,点击也是一样可以跳转进app的
跳转页面的时候还可以通过 ?key=value&key1=value2 键值对的方式往地址后面拼接参数
Intent intent = getIntent(); Uri uri = intent.getData(); assert uri != null; sb.append("scheme: ").append(intent.getScheme()).append("
"); sb.append("host: ").append(uri.getHost()).append("
"); sb.append("port: ").append(uri.getPort()).append("
"); sb.append("path: ").append(uri.getPath()).append("
"); sb.append("params: ").append(uri.getQuery()).append("
"); //获取跳转过来携带所有参数的 键名 Set
"); } tv.setText(Html.fromHtml(sb.toString()));
打开微信
打开QQ
效果图: