简体   繁体   中英

Android open external IMDB application from my app

I have a button in my application which opens the imdb application in the phone with a imdb id I received from https://developers.themoviedb.org/3/getting-started/introduction

But I couldnt find anyway(using intents) to make my app recognize the imdb app and open it and if imdb app do not exist then I want to open the web site. How can I accomplish this?

I think I may be able to point you in the right direction. Just to be sure, you seem to be using TMDB but wish to open in the IMDB app?

The code below is from the Android documentation .

It will start your intent if the package manager can find an app with the appropriate intent filter installed on your device. If multiple apps are able to open this intent then an app chooser should pop up, unless the user has previously set a default for this kind of URI.

  Intent sendIntent = new Intent(Intent.ACTION_SEND);
  // Always use string resources for UI text.
  // This says something like "Share this photo with"
  String title = getResources().getString(R.string.chooser_title);
  // Create intent to show the chooser dialog
  Intent chooser = Intent.createChooser(sendIntent, title);

  // Verify the original intent will resolve to at least one activity
  if (sendIntent.resolveActivity(getPackageManager()) != null) {
      startActivity(chooser);
  }

If you add an else onto that then you can use a view intent like this :

Intent internetIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(movieUrl));
//Watch out here , There is a URI and Uri class!!!!
if (internetIntent.resolveActivity(getPackageManager()) != null){
    startActivity(internetIntent);
}

I also found this (rather old) post about calling an explicit imdb uri Imdb description

startActivity(android.intent.action.VIEW, imdb:///title/<titleID>);
// take note of the Uri scheme "imdb"

I hope this helps. If you post some more detail , code, links , I might be able to work through this with you.

If my answer is way off base then please be kind and set me right. We are all learning every day! Good Luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM