伺服器下發跳轉路徑,客戶端根據 伺服器下發跳轉路徑跳轉相應的頁面
zymobi://3g2win:9999/macthdetail?macthid=222&time=10001
scheme
代表該schema 協議名稱
zymobi
host
代表schema作用於哪個位址域
3g2win
port
代表該路徑的埠號
9999
path
代表schema指定的頁面
/macthdetail
–代表傳遞的引數
?macthid=222&time=10001
在androidmanifest.xml中對activity標籤增加intent-filter設定schema
注意:android:name=".secondactivity">
android:name="android.intent.action.view"/>
android:name="android.intent.category.default"/>
android:name="android.intent.category.browsable"/>
android:scheme="zymobi"
android:host="3g2win"
android:port="9999"
android:path="/macthdetail"
/>
intent-filter>
activity>
必須配置,scheme不能配置在程式的入口類中否則不起作用。android:name="android.intent.action.view"/>
android:name="android.intent.category.default"/>
android:name="android.intent.category.browsable"/>
1.在html中呼叫非常簡單
href="zymobi://3g2win:9999/macthdetail?macthid=222&time=10001">開啟源生應用指定的頁面a>
2.在源生應用中呼叫也很簡單
intent intent = new intent(intent.action_view,uri.parse("zymobi://3g2win:9999/macthdetail?macthid=222&time=10001"));
startactivity(intent);
輸出結果intent intent = getintent();
uri data
= intent.getdata(); //
string action = intent.getaction();
string scheme = intent.getscheme();
set<
string
> categories = intent.getcategories();
log.e("tag", "data**********="
+data);
log.e("tag", "action**********="
+action);
log.e("tag", "categories**********="
+categories);
log.e("tag", "datastring**********="
+intent.getdatastring());
log.e("tag", "******************************");
log.e("tag", "scheme**********="
+scheme);
log.e("tag", "id **********="
+data
.getqueryparameternames());
log.e("tag", "host**********="
+data
.gethost());
log.e("tag", "path**********="
+data
.getpath());
log.e("tag", "port**********="
+data
.getport());
具體含義可以對比傳入的引數4-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
.action
.view
04-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
04-11
18:13:56.335
5198-5198/com
.phone
判斷schema是否有效,也可以說判斷應用是否安裝(在確定要啟動的應用已經配置了scheme)
intent intent = newintent(intent.action_view, uri.parse("zymobi://3g2win:9999/macthdetail?macthid=222&time=10001"));
listactivities =packagemanager.queryintentactivities(intent, 0);
boolean isvalid = !activities.isempty();
toast.maketext(this,isvalid+"",toast.length_long).show();
**:
Android 中Scheme協議的使用詳解
一 首先什麼是scheme?客戶端應用可以向系統註冊乙個 url scheme,該scheme用於從瀏覽器或其他應用中啟動本應用。通過指定的 url 字段,可以讓應用在被調起後直接開啟某些特定頁面。也可以執行某些指定動作。綜上scheme使用場景大致分以下幾種 1.伺服器下發跳轉路徑,客戶端根據伺服...
Unity中的協程
1.建立協程 迭代器 ienumerator private ienumerator test 裡面可以使用 yield return new waitforsecond 1 等待1s後執行後面的 yield return new waitforseconds 0.3f 等待0.3秒,一段指定的時間...
Unity中協程方法使用
開啟協程 void start 返回值是ienumerator 返回引數時使用 yield return null 協程方法的呼叫是startcoroutine changecolor ienumerator changecolor 關閉協程 關閉協程的方法需要和開啟協程的方法對應 不能使用star...