Skip to content Skip to sidebar Skip to footer

Check If Intent Uri Is Available

I have an app that sometimes links to imdb. I can do this with http://m.imdb.com/find or if it is available imdb:///find. My trouble is I can't find a way to check whether the imdb

Solution 1:

You can use resolveActivity() to detect whether there is any Activity in the system capable of handling your intent. Of course you need to construct the intent that mimics the "uri" click. That might be done using Intent.setData() function, though I didn't test/verify that myself.


Solution 2:

Following worked for me:

    Intent intent = new Intent();
    intent.setAction("android.intent.action.VIEW");
    Uri uri = Uri.parse("imdb:///title/tt1457767/");
    intent.setData(uri);
    this.getActivity().startActivity(intent);

You can replace String in Uri.parse("");with any of followings:

            imdb:///name/<nameID>
            imdb:///find?q=<search_query>
            imdb:///title/<titleID>
            imdb:///boxoffice
            imdb:///name/<nameID>
            imdb:///find?q=toystory

Post a Comment for "Check If Intent Uri Is Available"