Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to let user know he/she needs to install another app that my app depends on

I am developing an application which has defined some intent filters (in the form of action strings, e.g. com.example.project.UPLOAD) for other applications to use. Consider a device that didn't have my application but with applications that use my intent filters, the Intent created will fail the action test as described in the documentation. Is there any way to prevent this happening or give a better user experience? Here are some of the approaches I can think of but don't know if there are feasible:

  1. While installing an application that depends on another applications to handle some of the intents, suggest user to install the application that can handle the intent
  2. Dynamically determine if the intent can be handled. If not, launch the market showing the application that can handle the intent

What is the best approach to handle this? Please provide some implementation references if possible.

like image 942
pinglamb Avatar asked May 22 '11 17:05

pinglamb


People also ask

How do I send intent to another app?

Intent shareIntent = Intent. createChooser(sendIntent, null); startActivity(shareIntent); Optionally, you can add extras to include more information, such as email recipients ( EXTRA_EMAIL , EXTRA_CC , EXTRA_BCC ), the email subject ( EXTRA_SUBJECT ), and so on.

How do I start an activity in another application?

If both application have the same signature (meaning that both APPS are yours and signed with the same key), you can call your other app activity as follows: Intent LaunchIntent = getActivity(). getPackageManager(). getLaunchIntentForPackage(CALC_PACKAGE_NAME); startActivity(LaunchIntent);

What is an intent filter?

An intent filter declares the capabilities of its parent component — what an activity or service can do and what types of broadcasts a receiver can handle. It opens the component to receiving intents of the advertised type, while filtering out those that are not meaningful for the component.


1 Answers

Aside from mentioning it in the Marketplace, I'm not sure how you'd go about presenting messages during the application installation, as (to my knowledge) there is no supported way to execute code upon installation.

If other applications use your filters, then it's up to them to make sure your package is installed. You can't really give them anything without being installed.

They can test to see if a package is installed using the PackageManager, and adjust their logic to notify the user when they need to install your package. Example:

private boolean isInstalled(){
    ComponentName comp = new ComponentName("com.yourpackagestuff", "com.yourpackagestuff.TestClass");
    Intent intentName = new Intent().setComponent(comp);
    List <ResolveInfo> list = ctx.getPackageManager().queryIntentActivities(intentName, PackageManager.MATCH_DEFAULT_ONLY);
    return list.size() > 0;
}

That's how I'd go about it, at least.

like image 193
Turnsole Avatar answered Nov 14 '22 23:11

Turnsole