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?
In android, we can lunch other applications using packing name. This example demonstrate about How to Launch an application from another application on Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.
At the simplest level, there are two different ways for apps to interact on Android: via intents, passing data from one application to another; and through services, where one application provides functionality for others to use.
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); }
which calls
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
Short answer: No, you cannot automatically install other applications as dependencies.
Longer answer:
Android Market does not let you declare other applications to install as a dependency. As a system, Market appears to be designed for single application installs -- not Linux distro style mega dependency graphs.
At runtime, you can test for installed apps and punt your user over to the Market if so. See the techniques suggested by @QuickNick (testing if an app is installed) and @TerryProbert (punting to market) if that's what you want.
Your best bet is probably to design your app to gracefully degrade if dependencies are not available, and suggest (or insist) that they head over to market to install them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With