android webview(外部瀏覽器)調起app


  最近寫的項目中涉及外部瀏覽器以及項目webview中調起app,所以總結下,和大家分享下。

  總的實現方法還是比較簡單的,

  1:在清單中注冊

  首先在AndroidManifest文件中,注冊一個過濾器

 

<intent-filter >
<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="xxx" android:host="xxx"/>
</intent-filter>

其中scheme和host如下:

scheme://host:port/path

例如:nearbar://com.nearbar.android:200/folder/subfolder/etc 
\---------/  \---------------------------/ \---/ \--------------------------/ 
scheme                 host               port        path 
                \--------------------------------/ 
                          authority    

2:在mainactivity中接收

  

if (Intent.ACTION_VIEW.equals(action)) {
Uri uri = i_getvalue.getData();
String data = uri.toString();

}

由於我的項目中url中傳過來的是json串,通過解析來判斷具體的操作。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM