问题描述
如果我创建了一个依赖于另一个或多个应用程序的应用程序(例如: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.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();
}
然后在整理出所有代码后,我意识到您要求在 与您的应用程序同时安装它.不确定我是否应该发布此代码,但它可能会有所帮助
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应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!