【发布时间】:2015-04-09 19:27:22
【问题描述】:
我试图获取被点击的 URL 以打开应用程序。我只是很难找到我可以得到这些信息的地方。我有一个清单,单击时会打开应用程序。该链接将是“http://host.com/file.html?param=1¶m2=2”,我试图将其提供给应用程序来处理。
<intent-filter>
<data android:scheme="http"
android:host="host.com"
android:pathPrefix="/file.html" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
编辑
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = getIntent();
Uri uri = intent.getData();
try {
url = new URL(uri.getScheme(), uri.getHost(), uri.getPath());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
【问题讨论】: