Android業務コンポーネント化のURL Schemeは使用します.
8256 ワード
文章が自然に変わるhttp://blog.csdn.net/hunterliy/article/details/54631528
URL Schemeとは?
androidの中のschemeはページ内のジャンププロトコルであり、非常に良い実現メカニズムであり、自分のschemeプロトコルを定義することによって、アプリの各ページに非常に便利にジャンプできます.schemeプロトコルを通じて、サーバーはAppにそのページをジャンプするようにカスタマイズできます.通知欄のメッセージを通じてジャンプページをカスタマイズすることができます.H 5ページを通じてページなどをジャンプすることができます.
URL Scheme応用シーン:
クライアントアプリケーションは、ブラウザまたは他のアプリケーションから本アプリケーションを起動するためのURL schemeをオペレーティングシステムに登録することができる.指定されたURLフィールドを通じて、商品の詳細ページやイベントの詳細ページなど、調整された後に直接特定のページを開くようにすることができます.支払いが完了するなど、特定の動作を実行することもできます.アプリケーション内でhtmlページを通じて直接にアプリ内のあるページを呼び出すこともできます.上記URL Schemeの使用シーンは大体以下の種類に分けられます.サーバの下で、クライアントはサーバの下でジャンプする経路に従って、対応するページ をジャンプします. H 5ページはアンカーポイントをクリックし、アンカーポイントの具体的なジャンプパスAPPの端から具体的なページ をジャンプします. APP端末はサーバからPUSH通知欄のメッセージを受信し、メッセージのクリック・ジャンプ経路によって関連ページ にジャンプする. APPはURLから別のAPP指定ページ にジャンプします.
URL Schemeプロトコルフォーマット:
まず完全なURL Schemeプロトコルフォーマットをください. xlはSchemeプロトコル名 を表す. goodsはSchemeを代表してどの住所域の に役立ちますか? goods Detail代表Scheme指定ページ goodsIdは、伝達するパラメータ を表す. 8888は、パスのポート番号 を表しています.
URL Schemeはどう使いますか?
1)Android Manifest.xmlにラベルの追加設定Scheme
ホームページ
Schemeの基本的な使い方はこれだけです.他のものは後で使う時にまとめます.
URL Schemeとは?
androidの中のschemeはページ内のジャンププロトコルであり、非常に良い実現メカニズムであり、自分のschemeプロトコルを定義することによって、アプリの各ページに非常に便利にジャンプできます.schemeプロトコルを通じて、サーバーはAppにそのページをジャンプするようにカスタマイズできます.通知欄のメッセージを通じてジャンプページをカスタマイズすることができます.H 5ページを通じてページなどをジャンプすることができます.
URL Scheme応用シーン:
クライアントアプリケーションは、ブラウザまたは他のアプリケーションから本アプリケーションを起動するためのURL schemeをオペレーティングシステムに登録することができる.指定されたURLフィールドを通じて、商品の詳細ページやイベントの詳細ページなど、調整された後に直接特定のページを開くようにすることができます.支払いが完了するなど、特定の動作を実行することもできます.アプリケーション内でhtmlページを通じて直接にアプリ内のあるページを呼び出すこともできます.上記URL Schemeの使用シーンは大体以下の種類に分けられます.
URL Schemeプロトコルフォーマット:
まず完全なURL Schemeプロトコルフォーマットをください.
xl://goods:8888/goodsDetail?goodsId=10011002
1 2 上記の経路Scheme、Host、port、path、queryを全部含めて、基本的には通常の使用経路はこのようです.URL Schemeはどう使いますか?
1)Android Manifest.xmlにラベルの追加設定Scheme
<activity
android:name=".GoodsDetailActivity"
android:theme="@style/AppTheme">
<intent-filter>
<data android:scheme="xl" android:host="goods" android:path="/goodsDetail" android:port="8888"/>
<category android:name="android.intent.category.DEFAULT"/>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.BROWSABLE"/>
intent-filter>
activity>
1 2 3 4 5 6 7 8 9 10 11 12 13 2)Schemeジャンプのパラメータを取得するUri uri = getIntent().getData();
if (uri != null) {
// url
String url = uri.toString();
Log.e(TAG, "url: " + uri);
// scheme
String scheme = uri.getScheme();
Log.e(TAG, "scheme: " + scheme);
// host
String host = uri.getHost();
Log.e(TAG, "host: " + host);
//port
int port = uri.getPort();
Log.e(TAG, "host: " + port);
//
String path = uri.getPath();
Log.e(TAG, "path: " + path);
List<String> pathSegments = uri.getPathSegments();
// Query
String query = uri.getQuery();
Log.e(TAG, "query: " + query);
//
String goodsId = uri.getQueryParameter("goodsId");
Log.e(TAG, "goodsId: " + goodsId);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 3.呼び出し方式ホームページ
<a href="xl://goods:8888/goodsDetail?goodsId=10011002"> a>
1 コールIntent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("xl://goods:8888/goodsDetail?goodsId=10011002"));
startActivity(intent);
1 2 4.Schemeが有効かどうかをどう判断するか?PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("xl://goods:8888/goodsDetail?goodsId=10011002"));
List activities = packageManager.queryIntentActivities(intent, 0);
boolean isValid = !activities.isEmpty();
if (isValid) {
startActivity(intent);
}
1 2 3 4 5 6 7 締め括りをつけるSchemeの基本的な使い方はこれだけです.他のものは後で使う時にまとめます.