首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何制作依赖于其他应用的Android应用?

如何制作依赖于其他应用的Android应用?
EN

Stack Overflow用户
提问于 2018-03-21 02:08:07
回答 2查看 0关注 0票数 0

如果我创建的应用程序依赖于另一个应用程序,但它们未安装,是否有方法检查这些依赖关系并将它们与我自己的应用程序同时安装?

EN

Stack Overflow用户

发布于 2018-03-21 11:00:11

我在我的应用程序中这样做了,它需要安装zxing扫描仪应用程序。你会想要在你的onclick或ontouch中:

代码语言:javascript
复制
try{
    Intent intent = new Intent("com.google.zxing.client.android.SCAN");
    intent.setPackage("com.google.zxing.client.android");
    startActivityForResult(intent, 0);
} catch (Exception e) {
    createAlert("Barcode Scanner not installed!", "This application uses " +
    "the open source barcode scanner by ZXing Team, you need to install " +
    "this before you can use this software!", true);
}

还有调用下这段代码:

代码语言:javascript
复制
public void createAlert(String title, String message, Boolean button) {
    // http://androidideasblog.blogspot.com/2010/02/how-to-add-messagebox-in-android.html
    AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(this).create();
    alertDialog.setTitle(title);
    alertDialog.setMessage(message);
    if ((button == true)) {
        alertDialog.setButton("Download Now",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface arg0, int arg1) {
                Intent browserIntent = new Intent(
                    Intent.ACTION_VIEW,
                    Uri.parse("market://search?q=pname:com.google.zxing.client.android"));
                startActivity(browserIntent);
            }
        });
    }
    alertDialog.show();
}
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100003650

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档