Androidはurlを通じてアプリを開き、アプリをダウンロードします.
5409 ワード
一.Custom Scheme URIを使ってAPPを開く
この赤い部分(カスタムUri)が引用しているブログは以下の通りです.http://blog.csdn.net/buptlzx/article/details/9837137 androidコードによると、主に二つのブロックの一部が登録ファイルであり、以下の通りである.
この赤い部分(カスタムUri)が引用しているブログは以下の通りです.http://blog.csdn.net/buptlzx/article/details/9837137
Android ,URI :scheme, authority and path。 authority host port。 :
scheme://host:port/path 実際の例を挙げます.content://com.example.project:200/folder/subfolder/etc ?arg 0=1&arg 1=2——————————————————————————————————————————————————————————————————————————//(query私たちが伝えたい値)scheme host port path(私たちが伝えたい値が複数の値を伝えるなら使用&)—————————————————————————————————————————————————————————————————————————————————————————— <intent-filter>
<data
android:host="com.example.project"
android:port="200"
android:scheme="content" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
intent-filter>
2.もう一つの部分はappトップページの解析ページのコードは以下の通りです. Intent intent = getIntent();
Uri uri=intent.getData();
if(uri!=null){
String name=uri.getQueryParameter("arg0");
String name1=uri.getQueryParameter("arg1");
String scheme= uri.getScheme();
String host=uri.getHost();
String port=uri.getPort()+"";
String path=uri.getPath();
String query=uri.getQuery();
}
二.パッケージ名で第三者アプリを開き、パッケージ名がない場合はアドレス指定で該当アプリをダウンロードする. try {
Intent intent = wm.getPackageManager().getLaunchIntentForPackage(appPackageName);
Bundle bundle = new Bundle();
bundle.putString("s","d");
intent.putExtras(bundle);
wm.startActivity(intent);
return;
} catch (Exception e) {
downloadAddress = downloadAdd;
BaseDialog dialog = new BaseDialog();
dialog.setTitle(" ");
dialog.setContent(" “" + DelegateDataBase.ENTRUST_LIST[index] + "” ?");
dialog.setConfirm(" ", new BaseDialog.DialogListener() {
@Override
public void onListener() {
Uri uri = Uri.parse(downloadAddress.toString());
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
wm.startActivity(intent);
}
});
dialog.setCancel(" ", null);
dialog.show(wm);
}