How to Check If Facebook Is Installed Android

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



Leave a reply



Submit