我正在开发一个下载图片的应用程序。我已经成功地触发我的应用程序时,用户点击下载图像link.How我是否过滤特定的网址?
下面是我的清单代码:
<activity android:theme="@style/Transparent" android:name=".DownloadImage"
android:label="@string/app_name">
<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:mimeType="image/*" android:host="*"
android:scheme="http" />
</intent-filter>
</activity>我的应用程序将在用户单击浏览器中的任何链接时启动和下载图像,但不会在特定的url上触发,例如"http://www.ABC.com“或特定项目"http://www.ABC.com/image/background.jpg”
发布于 2012-06-09 15:43:46
当您的应用程序调用下载图像时,您应该浏览link:
Intent intent = getIntent();
String link = intent.getDataString();发布于 2012-11-30 11:34:23
在这里查看数据标记的其他有用属性(pathPattern、pathPrefix):http://developer.android.com/guide/topics/manifest/data-element.html。
发布于 2013-03-01 02:54:47
通过从意图过滤器获取url简单示例:
public class openUrl extends Activity{
String link;
TextView text;
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.xmlname);
Intent intent = getIntent();
link = intent.getDataString();
text = (TextView)findViewById(R.id.textViewId);
text.setText(link.toString());
}
}https://stackoverflow.com/questions/6907373
复制相似问题