开发者

android filter url in "intent-filter"

I'm developing a application for download image. I have successful to trigger my app when the user click the download image link.How do i filter the specific URL?

here my manifest code :

<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>

my application will launch and download the image when user click any link in browser but not trigger on specific url, for example "http://www.ABC.com" or the specific item "http://www.ABC.com/image/background.jpg"


when your application called for download image you should explore link:

    Intent intent = getIntent();
    String link = intent.getDataString();


See other useful attributes (pathPattern, pathPrefix) of the data tag here: http://developer.android.com/guide/topics/manifest/data-element.html.


Simple example by get url from intent filter:

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());
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜