Question:
I start skype with the following code.
Intent skype_intent = new Intent("android.intent.action.VIEW");
skype_intent.setClassName("com.skype.raider", "com.skype.raider.Main");
skype_intent.setData(Uri.parse("skype: skype_name"));
startActivity(skype_intent);
Everything is fine. But if there is no skype on the phone, then the application crashes. How can I call skype differently so that it doesn't crash the application or check for skype on my phone. If you have run the code, if not, display "You don't have skype"?
Answer:
I think this code does not need an explanation:
private boolean isAppInstalled(String packageName) {
PackageManager pm = getPackageManager();
boolean installed = false;
try {
pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
installed = true;
} catch (PackageManager.NameNotFoundException e) {
installed = false;
}
return installed;
}