導航:首頁 > 操作系統 > android瀏覽器打開應用

android瀏覽器打開應用

發布時間:2022-06-27 23:48:20

『壹』 在android手機如何通過瀏覽器URL鏈接打開android應用

在activity里加上如下即可,在觸發url的時候你的應用會和瀏覽器一起顯示在選項列表裡,選擇了你的應用就用你的應用打開了
<intent-filter>
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

『貳』 怎麼在android實現通過瀏覽器點擊鏈接打開apk

為了實現這個功能可折騰了好久,先上一份代碼,經樓主驗證是絕對可以用的而且也比較清晰的代碼!(ps:還是先劇透下吧,第三方大部分瀏覽器無法成功。)
點擊瀏覽器中的URL鏈接,啟動特定的App。

首先做成HTML的頁面,頁面內容格式如下:
<a href="[scheme]://[host]/[path]?[query]">啟動應用程序</a>
這一句就可以了。
各個項目含義如下所示:
scheme:判別啟動的App。 ※詳細後述
host:適當記述
path:傳值時必須的key ※沒有也可以
query:獲取值的Key和Value ※沒有也可以

作為測試好好寫了一下,如下:
<a href="myapp://jp.app/openwith?name=zhangsan&age=26">啟動應用程序</a>
接下來是Android端。
首先在AndroidManifest.xml的MAIN Activity下追加以下內容。(啟動Activity時給予)
※必須添加項
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
HTML記述的內容加入<data …/>。
其中必須的內容僅scheme,沒有其他內容app也能啟動。
※注意事項:intent-filter的內容【android.intent.action.MAIN】和 【android.intent.category.LAUNCHER】這2個,不能與這次追加的內容混合。
所以,如果加入了同一個Activity,請按以下這樣做,否則會導致應用圖標在桌面消失等問題。
復制代碼
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
復制代碼
這樣的話,沒有問題。

接下來在Activity中需要取值的地方添加以下代碼,是直接寫在OnCreate函數里的:

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

if(Intent.ACTION_VIEW.equals(action)){
Uri uri = i_getvalue.getData();
if(uri != null){
String name = uri.getQueryParameter("name");
String age= uri.getQueryParameter("age");
}
}

這樣就能獲取到URL傳遞過來的值了。

『叄』 怎麼在android實現通過瀏覽器點擊鏈接打開apk

為了實現這個功能可折騰了咱好久,先上一份代碼,經驗證是絕對可以用的而且也比較清晰的代碼!(ps:還是先劇透下吧,第三方大部分瀏覽器無法成功。)
點擊瀏覽器中的URL鏈接,啟動特定的App。

首先做成HTML的頁面,頁面內容格式如下:
<a href="[scheme]://[host]/[path]?[query]">啟動應用程序</a>
這一句就可以了。
各個項目含義如下所示:
scheme:判別啟動的App。 ※詳細後述
host:適當記述
path:傳值時必須的key ※沒有也可以
query:獲取值的Key和Value ※沒有也可以

作為測試好好寫了一下,如下:
<a href="myapp://jp.app/openwith?name=zhangsan&age=26">啟動應用程序</a>
接下來是Android端。
首先在AndroidManifest.xml的MAIN Activity下追加以下內容。(啟動Activity時給予)
※必須添加項
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
HTML記述的內容加入<data …/>。
其中必須的內容僅scheme,沒有其他內容app也能啟動。
※注意事項:intent-filter的內容【android.intent.action.MAIN】和 【android.intent.category.LAUNCHER】這2個,不能與這次追加的內容混合。
所以,如果加入了同一個Activity,請按以下這樣做,否則會導致應用圖標在桌面消失等問題。
復制代碼
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
復制代碼
這樣的話,沒有問題。

接下來在Activity中需要取值的地方添加以下代碼,咱是直接寫在OnCreate函數里的:

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

if(Intent.ACTION_VIEW.equals(action)){
Uri uri = i_getvalue.getData();
if(uri != null){
String name = uri.getQueryParameter("name");
String age= uri.getQueryParameter("age");
}
}

這樣就能獲取到URL傳遞過來的值了。

『肆』 怎麼在android實現通過瀏覽器點擊鏈接打開apk

為了實現這個功能可折騰了我好久,先上一份代碼,經樓主驗證是絕對可以用的而且也比較清晰的代碼!(ps:還是先劇透下吧,第三方大部分瀏覽器無法成功。)
點擊瀏覽器中的URL鏈接,啟動特定的App。

首先做成HTML的頁面,頁面內容格式如下:
<a href="[scheme]://[host]/[path]?[query]">啟動應用程序</a>
這一句就可以了。
各個項目含義如下所示:
scheme:判別啟動的App。 ※詳細後述
host:適當記述
path:傳值時必須的key ※沒有也可以
query:獲取值的Key和Value ※沒有也可以

作為測試好好寫了一下,如下:
<a href="myapp://jp.app/openwith?name=zhangsan&age=26">啟動應用程序</a>
接下來是Android端。
首先在AndroidManifest.xml的MAIN Activity下追加以下內容。(啟動Activity時給予)
※必須添加項
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>

『伍』 在android手機如何通過瀏覽器URL鏈接打開android應用

在activity里加上如下即可,在觸發url的時候你的應用會和瀏覽器一起顯示在選項列表裡,選擇了你的應用就用你的應用打開了

『陸』 怎麼在android實現通過瀏覽器點擊鏈接打開apk

為了實現這個功能可折騰了我好久,先上一份代碼,經樓主驗證是絕對可以用的而且也比較清晰的代碼!(ps:還是先劇透下吧,第三方大部分瀏覽器無法成功。)
點擊瀏覽器中的URL鏈接,啟動特定的App。

首先做成HTML的頁面,頁面內容格式如下:
<a href="[scheme]://[host]/[path]?[query]">啟動應用程序</a>
這一句就可以了。
各個項目含義如下所示:
scheme:判別啟動的App。 ※詳細後述
host:適當記述
path:傳值時必須的key ※沒有也可以
query:獲取值的Key和Value ※沒有也可以

作為測試好好寫了一下,如下:
<a href="myapp://jp.app/openwith?name=zhangsan&age=26">啟動應用程序</a>
接下來是Android端。
首先在AndroidManifest.xml的MAIN Activity下追加以下內容。(啟動Activity時給予)
※必須添加項
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
HTML記述的內容加入<data …/>。
其中必須的內容僅scheme,沒有其他內容app也能啟動。
※注意事項:intent-filter的內容【android.intent.action.MAIN】和 【android.intent.category.LAUNCHER】這2個,不能與這次追加的內容混合。
所以,如果加入了同一個Activity,請按以下這樣做,否則會導致應用圖標在桌面消失等問題。
復制代碼
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
復制代碼
這樣的話,沒有問題。

『柒』 怎麼在android實現通過瀏覽器點擊鏈接打開apk

點擊瀏覽器中的URL鏈接,啟動特定的App。

首先做成HTML的頁面,頁面內容格式如下:
<a href="[scheme]://[host]/[path]?[query]">啟動應用程序</a>
這一句就可以了。
各個項目含義如下所示:
scheme:判別啟動的App。 ※詳細後述
host:適當記述
path:傳值時必須的key ※沒有也可以
query:獲取值的Key和Value ※沒有也可以

作為測試好好寫了一下,如下:
<a href="myapp://jp.app/openwith?name=zhangsan&age=26">啟動應用程序</a>
接下來是Android端。
首先在AndroidManifest.xml的MAIN Activity下追加以下內容。(啟動Activity時給予)
※必須添加項
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
HTML記述的內容加入<data …/>。
其中必須的內容僅scheme,沒有其他內容app也能啟動。
※注意事項:intent-filter的內容【android.intent.action.MAIN】和 【android.intent.category.LAUNCHER】這2個,不能與這次追加的內容混合。
所以,如果加入了同一個Activity,請按以下這樣做,否則會導致應用圖標在桌面消失等問題。
復制代碼
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
復制代碼
這樣的話,沒有問題。

接下來在Activity中需要取值的地方添加以下代碼,我是直接寫在OnCreate函數里的:

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

if(Intent.ACTION_VIEW.equals(action)){
Uri uri = i_getvalue.getData();
if(uri != null){
String name = uri.getQueryParameter("name");
String age= uri.getQueryParameter("age");
}
}

這樣就能獲取到URL傳遞過來的值了。

——————————————————————————————————我是分割線————————————————————————————————————

代碼完了,是不是很驚奇的發現用瀏覽器輸入
myapp://jp.app/openwith?name=zhangsan&age=26
是不是404,打不開?
樓主你這不是騙人么!樓主你個混蛋啊。
客官,稍安勿躁啊,你看看你用的瀏覽器是什麼?UC,獵豹,歐朋?放棄吧,試試系統自帶瀏覽器或者谷歌瀏覽器吧。肯定能成功的,不能成功的話再來坑我。哈哈。

——————————————————————————————————我是分割線————————————————————————————————————
突然覺得好悲哀,好不容易get了這個技能,卻不能被第三方瀏覽器使用。在這個android瀏覽器大部分被第三方占據著的時代不得不說是個悲劇啊。

接下來還是說說為什麼第三方瀏覽器不能成功吧。首先,我發現的是UC瀏覽器,如果你使用了自己的scheme,而不是http的話,uc會默認在你的scheme前面添加http://。這太坑爹了。其他瀏覽器沒看是不是同樣的情況。發現這個問題後我就試著把自己的scheme換成http。然後滿懷期待的又跑了一遍,結果還是坑爹了。所以我想會不會是第三方瀏覽器對url做了處理。到這里,我也無可奈何了。我測試了UC,獵豹,歐朋,這3個都不支持。系統自帶的和谷歌瀏覽器是支持的。

『捌』 怎麼在android實現通過瀏覽器點擊鏈接打開apk

android實現通過瀏覽器點擊鏈接打開本地應用(APP)並拿到瀏覽器傳遞的數據
方法/步驟
為了實現這個功能可折騰了我好久,先上一份代碼,經樓主驗證是絕對可以用的而且也比較清晰的代碼!(ps:還是先劇透下吧,第三方大部分瀏覽器無法成功。)
點擊瀏覽器中的URL鏈接,啟動特定的App。

首先做成HTML的頁面,頁面內容格式如下:
<a href="[scheme]://[host]/[path]?[query]">啟動應用程序</a>
這一句就可以了。
各個項目含義如下所示:
scheme:判別啟動的App。 ※詳細後述
host:適當記述
path:傳值時必須的key ※沒有也可以
query:獲取值的Key和Value ※沒有也可以

作為測試好好寫了一下,如下:
<a href="myapp://jp.app/openwith?name=zhangsan&age=26">啟動應用程序</a>
接下來是Android端。
首先在AndroidManifest.xml的MAIN Activity下追加以下內容。(啟動Activity時給予)
※必須添加項
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
HTML記述的內容加入<data …/>。
其中必須的內容僅scheme,沒有其他內容app也能啟動。
※注意事項:intent-filter的內容【android.intent.action.MAIN】和 【android.intent.category.LAUNCHER】這2個,不能與這次追加的內容混合。
所以,如果加入了同一個Activity,請按以下這樣做,否則會導致應用圖標在桌面消失等問題。
復制代碼
<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="myapp" android:host="jp.app" android:pathPrefix="/openwith"/>
</intent-filter>
復制代碼
這樣的話,沒有問題。

接下來在Activity中需要取值的地方添加以下代碼,我是直接寫在OnCreate函數里的:

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

if(Intent.ACTION_VIEW.equals(action)){
Uri uri = i_getvalue.getData();
if(uri != null){
String name = uri.getQueryParameter("name");
String age= uri.getQueryParameter("age");
}
}

這樣就能獲取到URL傳遞過來的值了。

——————————————————————————————————我是分割線————————————————————————————————————

代碼完了,是不是很驚奇的發現用瀏覽器輸入
myapp://jp.app/openwith?name=zhangsan&age=26
是不是404,打不開?
樓主你這不是騙人么!樓主你個混蛋啊。
客官,稍安勿躁啊,你看看你用的瀏覽器是什麼?UC,獵豹,歐朋?放棄吧,試試系統自帶瀏覽器或者谷歌瀏覽器吧。肯定能成功的,不能成功的話再來坑我。哈哈。

——————————————————————————————————我是分割線————————————————————————————————————
突然覺得好悲哀,好不容易get了這個技能,卻不能被第三方瀏覽器使用。在這個android瀏覽器大部分被第三方占據著的時代不得不說是個悲劇啊。

接下來還是說說為什麼第三方瀏覽器不能成功吧。首先,我發現的是UC瀏覽器,如果你使用了自己的scheme,而不是http的話,uc會默認在你的scheme前面添加http://。這太坑爹了。其他瀏覽器沒看是不是同樣的情況。發現這個問題後我就試著把自己的scheme換成http。然後滿懷期待的又跑了一遍,結果還是坑爹了。所以我想會不會是第三方瀏覽器對url做了處理。到這里,我也無可奈何了。我測試了UC,獵豹,歐朋,這3個都不支持。系統自帶的和谷歌瀏覽器是支持的。

最後再補充個線索吧,在瀏覽器里搜索網路應用。進了他們的頁面後,他們是可以實現在各種瀏覽器啟動已經安裝好的本地app的。看到這個後我就看了下他們頁面的源碼

在這里他們頁面添加了個data-sentintent的標簽,看到這里,應該能確定第三方瀏覽器應該是默認都不支持發intent的,只能自己起一個。根據前端說,這個標簽應該是自定義的。我們前端看源碼的時候發現是這樣的

所以最後的結果應該是網路這邊是起了個埠,然後在應用里啟用了一個服務,來監聽這個埠,來獲取這個intent。大概就這個思路了。不過樓主沒有實際去操作。項目時間緊,太麻煩了。

閱讀全文

與android瀏覽器打開應用相關的資料

熱點內容
linux切換root命令 瀏覽:280
c編譯之後界面一閃而過怎麼辦 瀏覽:877
怎麼看ic卡是否加密 瀏覽:722
lgplc編程講座 瀏覽:806
cnc手動編程銑圓 瀏覽:720
cad中幾種命令的意思 瀏覽:324
oraclelinux安裝目錄 瀏覽:133
安卓系統可以安裝編譯器嗎 瀏覽:570
javajson實體類 瀏覽:690
板加密鋼筋是否取代原鋼筋 瀏覽:66
學習編程的思路 瀏覽:230
app易語言post怎麼學 瀏覽:965
地梁的箍筋加密區位置 瀏覽:302
二分法排序程序及編譯結果 瀏覽:679
日語命令形和禁止型 瀏覽:285
安裝軟體用管理員解壓 瀏覽:505
編譯原理代碼塊 瀏覽:400
小孩可以用壓縮面膜嗎 瀏覽:14
錐形倒角怎麼計演算法 瀏覽:883
java合並鏈表 瀏覽:508