How to check if Facebook is installed Android
com.facebook.android
is the package name for the Facebook SDK. The Facebook app's package is com.facebook.katana
.
Android: Check to see if Facebook app is present on user's device
Have you already checked this?
You can always check if an app is installed like this.
Facebook not installed on device but package com.facebook.katana exists
Is is not at all possible that android system show wrong information about an app as installed in device. In your case I have checked the code and it is completely ok, so the only reason why you are not being able to see facebook app in your device while the above code shows that package "com.facebook.katana" is -
Your facebook app is in disabled state
Yes, it seems that you were having facebook app as system app (pre installed to device) and now it is disabled. To check, you may go into your settings and find something like "Manage Applications". Go to the very bottom of the list in All Applications and you should find all the disabled apps there.
Check if application is installed - Android
Try this:
private boolean isPackageInstalled(String packageName, PackageManager packageManager) {
try {
packageManager.getPackageInfo(packageName, 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}
Note!
From Android 11 (API 30), you might need to declare <queries>
in your manifest, depending on what package you're looking for. Check out the docs for more info.
How it works:
It attempts to fetch information about the package whose name you passed in. Failing that, if a NameNotFoundException
was thrown, it means that no package with that name is installed, so we return false
.
Note that we pass in a PackageManager
instead of a Context
, so that the method is slightly more flexibly usable and doesn't violate the law of Demeter. You can use the method without access to a Context
instance, as long as you have a PackageManager
instance.
How to use:
public void someMethod() {
// ...
PackageManager pm = context.getPackageManager();
boolean isInstalled = isPackageInstalled("com.somepackage.name", pm);
// ...
}
How to check programmatically if an application is installed or not in Android?
Try with this:
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add respective layout
setContentView(R.layout.main_activity);
// Use package name which we want to check
boolean isAppInstalled = appInstalledOrNot("com.check.application");
if(isAppInstalled) {
//This intent will help you to launch if the package is already installed
Intent LaunchIntent = getPackageManager()
.getLaunchIntentForPackage("com.check.application");
startActivity(LaunchIntent);
Log.i("SampleLog", "Application is already installed.");
} else {
// Do whatever we want to do if application not installed
// For example, Redirect to play store
Log.i("SampleLog", "Application is not currently installed.");
}
}
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
return false;
}
}
Check facebook application installed or not in SocialSharing plugin for phonegap
If you are using this plugin than it already has option for checking whether Facebook or Other application is installed or not using this:
<button onclick="window.plugins.socialsharing.canShareVia('com.apple.social.facebook', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is facebook available on iOS?</button>
<button onclick="window.plugins.socialsharing.canShareVia('com.facebook.katana', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is facebook available on Android?</button>
First check using canShareVia function whether Facebook is installed & then use shareVia function..
Check plugin doc for more detail..
Related Topics
How to to Check If a User Has Rated Your App on the Google Play
Event Onclick for a Button in a Custom Notification
How to Save Image in Shared Preference in Android | Shared Preference Issue in Android with Image
How Does Native Android Code Written for Arm Run on X86
What Is the Use of Movetofirst () in SQLite Cursors
Android, Move Bitmap Along a Path
No Adapter Attached; Skipping Layout
Android -- How to Position View Off-Screen
How to Import Set of Icons into Android Studio Project
Animate Progressbar Update in Android
How to Check the Multiple Permission at Single Request in Android M
Javadoc in Eclipse Failing to Recognize Packages
Naming My Application in Android
Programmatically Add View One Below Other in Relative Layout
How to Use the Gradle Build System for Android with Eclipse
Android Volley Self Signed Https Trust Anchor for Certification Path Not Found
Can the Android Emulator Record and Play Back Audio Using Pc Hardware