【问题标题】:how to call Dictionary app using Android Intent [closed]如何使用 Android Intent 调用 Dictionary 应用程序 [关闭]
【发布时间】:2012-09-26 06:14:41
【问题描述】:

我的手机上安装了 Dictionary.com 应用程序。 我正在创建另一个应用程序,想知道如何使用 Intent 与 Dictionary 应用程序进行交互。

如果有什么办法请告诉我

【问题讨论】:

    标签: android android-intent dictionary


    【解决方案1】:

    您可以通过这种方式从您的应用程序中调用您的字典应用程序..

    这里 com.example.package.ActivityToStart 定义了您的字典应用程序

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName("com.example.package", "com.example.package.ActivityToStart");
    startActivity(intent);
    

    另一个最好的方法是

    try{
       PackageManager pm = getPackageManager();
       Intent intent = pm.getLaunchIntentForPackage("com.example.package");
       startActivity(intent);
    }catch (Exception e) {
       e.printStackTrace();
    }
    

    如果您不知道词典应用程序的包名,请查看this

    【讨论】:

    • 注意你必须try {} catch {}第二个选项,以防数据包不存在(NameNotFoundException)
    • 好的。我也接受@fliespl 的建议。感谢您的信息
    • 谢谢大家,我可以查看包并调用字典应用程序...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-23
    • 2019-01-29
    • 1970-01-01
    • 2016-07-10
    • 1970-01-01
    相关资源
    最近更新 更多