Reputation: 10737
I don't know how to ask if foursquare is installing in the phone and how to open foursquare.
I have this code in iPhone but now I don't know how to do in android. My code in objective-c is this:
NSString *urlSTR = [NSString stringWithFormat:@"foursquare://venues/%@", venueID];
NSURL *openFoursquare = [NSURL URLWithString:urlSTR];
if ( ![[UIApplication sharedApplication] openURL:openFoursquare] ) {
urlSTR = [NSString stringWithFormat:@"https://es.foursquare.com/v/%@", venueID];
openFoursquare = [NSURL URLWithString:urlSTR];
[[UIApplication sharedApplication] openURL:openFoursquare];
}
Any idea? I hope that somebody help me.
Upvotes: 0
Views: 75
Reputation: 8030
Try the following
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
// Activity not found, app not installed!
}
Or you can ask the PackageManager
if the package is installed with the following:
private boolean isPackageInstalled(String packagename, Context context) {
PackageManager pm = context.getPackageManager();
try {
pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
return true;
} catch (NameNotFoundException e) {
return false;
}
}
Upvotes: 1