简体   繁体   English

从我的应用程序启动Android视频应用程序

[英]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. 我正在尝试为Android 4.0.3创建一个应用程序,用于侦听UDP电报并启动其他应用程序,具体取决于收到的消息。

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) (特别是没有加载定义的视频,就像Action_View那样)

I was also thinking about using the StartApp, like the following: 我也在考虑使用StartApp,如下所示:

 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. Android平板电脑应该用作信息娱乐系统,我想使用“Ardoino Leonardo Ethernet”在最重要的应用程序之间切换,使用硬键代替触摸屏。

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". 我宁愿避免硬编码任何软件包名称,因为这样做会导致代码在不同的API和不同供应商的ROM上中断,因为它们包含自己的“播放器”和“观看者”。

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 您可以通过使用程序包管理器并对其进行查询来确定将安装哪些程序包以响应不同的Uri和Mime类型,即

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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