如何使Android应用程序依赖于另一个应用程序? [英] How to make an Android app that depends on another app?
问题描述
如果我创建一个取决于另一个应用程序或应用程序的应用程序(例如: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或者onuch中:
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应用程序依赖于另一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!