1. 程式人生 > >點選連結跳到指定的app

點選連結跳到指定的app

1.首先在app裡面MIANACTIVITY追加下面的內容

    

<activity
    android:name=".MainNovelActivity"
    android:resizeableActivity="false"
    android:screenOrientation="portrait"
    android:theme="@style/AppTheme.Welcome">
    <intent-filter>
        <action android:name="android.intent.action.MAIN"
/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT" /> <category android:name=
"android.intent.category.BROWSABLE" /> <data android:scheme="hpd"/> </intent-filter> </activity>
 
 
然後編輯指令碼html
<html>
<head>
 <meta charset="utf-8">
</head>
<body>
  <script>
     function isInstalled(){
		
var the_href=$(".down_app").attr("href");//獲得下載連結 window.location="apps custom url schemes";//開啟某手機上的某個app應用 setTimeout(function(){ window.location=the_href;//如果超時就跳轉到app下載頁 },500);     }     function doCallApp() {        window.location="hpd://bid/info?id=20170200019"     }   </script>   <br>   <a href="hpd://bid/info?id=20170200019">app link</a>   <br>   <br>   <button id="callApp" onclick="doCallApp()">Call App<tton> </body> <html>
然後在MAINACTIVITY裡面設定跳轉到特定介面的方法

 
Intent i_getvalue = getIntent();
String action = i_getvalue.getAction();

if(Intent.ACTION_VIEW.equals(action)) {

    Uri uri = i_getvalue.getData();
    if (uri != null) {
        String id = uri.getQueryParameter("id");
        Log.d("TAg",id);

        Intent intent = new Intent();
        intent.setClass(this, BorrowDetailsActivity.class);
        intent.putExtra(EXTRA_KEY_2, id);
        startActivity(intent);

    }
}