Reputation: 4059
I need to start another application from mine in the following order:
2.if no application is available, start Google Play and search for the name(eg "timer").
Upvotes: 0
Views: 149
Reputation: 8028
first you need to read all the installed app read more here http://www.androidsnippets.com/get-installed-applications-with-name-package-name-version-and-icon,
after you found the desire application, you can simple fire intent to that application or else open the market with filter search like this
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("market://search?q=com.amazon.kindle"));
startActivity(i);
Upvotes: 0
Reputation: 132982
you will need to use PackageManager
for getting all installed Applications name and use getLaunchIntentForPackage
for launching application if it contain specific string :
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages =
pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
if(packageInfo.packageName.toLowerCase().
contains(""perfect timer".toLowerCase())){
Intent intent =
pm.getLaunchIntentForPackage(packageInfo.packageName);
if (intent != null) {
intent.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(intent);
}
} else{
// Launch google play app here
String apppackname = "com.example.appname";
Intent intentapp=new (Intent.ACTION_VIEW,
Uri.parse("market://search?q="+apppackname)));
startActivity(intentapp);
}
}
Upvotes: 1