如何制作依赖于另一个应用程序的Android应用程序?

编程入门 行业动态 更新时间:2024-10-27 15:20:11
本文介绍了如何制作依赖于另一个应用程序的Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我创建了一个依赖于另一个或多个应用程序的应用程序(例如:Facebook 和 Twitter 应用程序),但它们尚未安装,是否有一种方法可以检查这些依赖项并与我自己的应用程序同时安装它们应用?

If I create an app that depends on another app or apps (eg: the Facebook and Twitter apps), yet they are not installed, is there a method of checking for those dependencies and installing them at the same time as my own app?

推荐答案

我在我的应用程序中做了这个,它需要安装 zxing 扫描仪应用程序.你会希望在你的 onclick 或 ontouch 中使用它:

I did this in my application which requires the zxing scanner app to be installed. You will want this inside your onclick or ontouch:

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

哪个调用

public void createAlert(String title, String message, Boolean button) {
    // http://androidideasblog.blogspot/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();
}

然后在整理出所有代码后,我意识到您要求在 与您的应用程序同时安装它.不确定我是否应该发布此代码,但它可能会有所帮助

Then after sorting out all that code out I realise you asked for it to be installed at the same time as your app. Not sure if i should post this code, but it may be helpful

这篇关于如何制作依赖于另一个应用程序的Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-19 13:00:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/645339.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   依赖于   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!