简体   繁体   中英

Launch the android Video App from my app

I am trying to create an app for Android 4.0.3 that listens for UDP-telegrams and starts other apps, depending on the received message.

I am already able to Launch some apps, like the "Music" app:

Intent intent = new Intent("android.intent.action.MUSIC_PLAYER");
intent.SetFlags(ActivityFlags.NewTask);
context.StartActivity(intent);

Is there any chance to do the same for the Video app? I dont find a valid command for that. (especially WITHOUT loading a defined Video, like Action_View would do)

I was also thinking about using the StartApp, like the following:

 OpenApp(context, "com.google.android.apps.maps");

But I also dont find a valid package-name for the Video app, like the other apps have.

Background: This is for a car-project. The Android-tablet should be used as infotainment system and I want to use an "Ardoino Leonardo Ethernet" to switch between the most important app, using hardkeys instead of the touchscreen.

I prefer to avoid hardcoding any package names as doing so will cause the code to break on different APIs and different vendor's ROMs as they include their own "players" and "viewers".

You can determine which packages are installed that will response to different Uri and Mime types by using the Package Manager and making a query to it, ie

var activityIntent = new Intent(Intent.ActionView);
activityIntent.SetDataAndTypeAndNormalize(Uri.Parse("pseudo.mp4"), "video/mp4");
var resolvedActivityList = PackageManager.QueryIntentActivities(activityIntent, PackageInfoFlags.MatchAll); 
foreach (var info in resolvedActivityList)
{
    Log.Debug("SO", info.ActivityInfo.ApplicationInfo.PackageName);
}

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