如何打开部件从Android中的外部应用程序? [英] how to open an external application from widget in android?

查看:151
本文介绍了如何打开部件从Android中的外部应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们点击那个时候我需要打开外部aplication(例如Netflix的应用程序)的小工具。如何做到这一点?

When we click the widget at that time i need to open an external aplication (for example netflix app).How to do this?

在所有的情况下,我觉得像<一个解决方案href=\"http://stackoverflow.com/questions/3589741/how-to-open-a-application-from-widget-in-android\">that但是,是不是我在寻找什么。

In all cases i find solutions like that but, is not what I'm looking.

谢谢!

推荐答案

要创建自己的外部应用小工具,你可以使用这个code:

To create your own widget for external apps, you can use this code:

PackageManager pm = getPackageManager();
      try
      {
       String packageName = "com.example.package";
       Intent launchIntent = pm.getLaunchIntentForPackage(packageName);
       startActivity(launchIntent);
      }
    catch (Exception e1)
    {
    }

因此​​,如果您还需要包名称就可以在Web浏览器中发现,在谷歌播放网站。

So if you need the package name you can find it in a web browser, in google play site.

然后,只需remplace在code:字符串的packageName =com.netflix.mediaclient;

and then, just remplace it in the code: String packageName = "com.netflix.mediaclient";

这篇关于如何打开部件从Android中的外部应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆