网页唤醒App

    xiaoxiao2021-12-02  14

    很多时候,微信,或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只需要单机的时候,跳到这个即可  

    转载请注明原文地址: https://ju.6miu.com/read-679720.html

    最新回复(0)