2

here is my code to call mxplayer but it didn't work, why ?

Intent myIntent ;
PackageManager manager = getPackageManager();
myIntent = manager.getLaunchIntentForPackage("com.mxtech.videoplayer.ad");
startActivity(myIntent);
Lol Pallau
  • 199
  • 2
  • 5
  • 15

2 Answers2

3

The developer of MX Player documented its package namespaces here: https://sites.google.com/site/mxvpen/api

So if you have installed the pro version, you need to use another name.

[Package]
com.mxtech.videoplayer.pro  - Pro Edition
com.mxtech.videoplayer.ad - Free Edition.

Further more you can catch the exception for the case, that the MX Player isn't installed on the system:

Intent myIntent;
    PackageManager pm = getPackageManager();
    try {
        myIntent = pm.getLaunchIntentForPackage(YourPackageName);
        if (null != myIntent)
            this.startActivity(myIntent);
    } catch (ActivityNotFoundException e) {

    }
Priyanka
  • 677
  • 5
  • 20
alex
  • 5,516
  • 2
  • 36
  • 60
  • You might also want to get a list of all installed apps with the package information, so you can check the name of the installed MX Player: http://stackoverflow.com/a/2696617/1965084 – alex Jan 28 '13 at 10:48
  • yeah ok thanks, in fact i was lauching my app with usb in and I forgot that mxplayer was on my sdcard which was desactivated when usb debbugging is on Just one thing when mx player is launched is there a way to disable the menu button ? – Lol Pallau Jan 28 '13 at 10:59
  • Do you want to diable a button, that was pressed to launch the MX Player? The i would just start the intent in the onclick event of the button and set the button there to enabled false: myButton.setEnabled(false); Then in the onResume() of your activity you can activate the button again, after the user return to your activity. Here you can find more information on the lifecycle of an activity: http://developer.android.com/reference/android/app/Activity.html – alex Jan 28 '13 at 13:39
1

The official explanation is to say, What is your program if there is an error message? Return a "good" intent to launch a front-door activity in a package, for use for example to implement an "open" button when browsing through packages.

iliaokun
  • 29
  • 1
  • i dicovered that my intent was null. I wanted to call an external app mx player : https://play.google.com/store/apps/details?id=com.mxtech.videoplayer.ad . So i took the package name to call it – Lol Pallau Jan 28 '13 at 10:07