网页唤醒App

很多时候,微信,或qq分享一个h5页面,或是运营的发了一个链接到推广上,当单机某个链接的时候,想跳到我们app的制定页面,

有时候还要根据不同的参数跳到不同的页面,


第一步:在清单里面配置如下,主要是的  scheme,名字阔以随便起,最好和后台统一

<activity
    android:name=".view.MainActivity"
    android:configChanges="screenSize|keyboardHidden|orientation"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>

        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.DEFAULT"/>

        <data android:scheme="qwy"/>
    </intent-filter>
</activity>
 
 
第二步:在配置的activity中,加入以下代码, 
以下的open方法,是根据传递的不同参数,转跳到不同的界面,
Intent i_getvalue = getIntent();
String action = i_getvalue.getAction();
if (Intent.ACTION_VIEW.equals(action)) {
    Uri uri = i_getvalue.getData();
    if (uri != null) {
        try {
            String strs[] = uri.toString().split("/");
            open(Integer.parseInt(strs[2]), Integer.parseInt(strs[3]));
        } catch (Exception e) {
            LogUtil.e("出错信息=" + e.toString());
        }
    }
}
private Intent proIntent;

private void open(int type, int id) {
    switch (type) {
        case 1:
            proIntent = new Intent(this, PostDetailsActivity.class);
            proIntent.putExtra("tid", id);
            break;
        case 2:
            proIntent = new Intent(this, SomeoneActivity.class);
            proIntent.putExtra("tips_uid", id);
            break;
        case 3:
            proIntent = new Intent(this, SqZhuboActivity.class);
            proIntent.putExtra("fid", id);
            break;
    }
    startActivity(proIntent);
}

第三步:h5界面的设置,
qwy://1/11
只需要单机的时候,跳到这个即可

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值