One might be working on an Android application and integrating it with Facebook to share a story, image or a game point scored, to do that the first thing that you would like to know is if Facebook is really installed on the device or not.
⛏️ com.facebook.katana is the package name for the Facebook app on Android.
Let's see how we can do this by creating a single java method,
- Create a method say isFacebookInstalled() that returns a boolean.
- Get the PackageManager instance using getPackageManager()
- Now declare a boolean flag and set it to false by default.
- In a try and catch block look for the package for Facebook: com.facebook.katana
- If it throws an exception then we do not have this package installed, just turn a false in this case.
You can create a method as below and check if the user has Facebook installed or not,
public Boolean checkFbInstalled() {
PackageManager pm = getPackageManager();
boolean flag = false;
try {
pm.getPackageInfo("com.facebook.katana", PackageManager.GET_ACTIVITIES);
flag = true;
} catch (PackageManager.NameNotFoundException e) {
flag = false;
}
return flag;
}
⛏️ Facebook is known via various package names as well, you can try using one of these,
- com.example.facebook
- com.facebook.katana
- com.facebook.orca
- com.facebook.android
⚠️ If you are integrating Facebook SDK with your application you may really not need to do this as the SDK framework can handle this.
Have Questions? Post them here!
- Android Error Unexpected cast to Button: layout tag was FrameLayout
- ADT quit unexpectedly error on Mac OSX Android Eclipse SDK
- Parsing Data for android-21 failed unsupported major.minor version 51.0
- Android Studio Ctrl Shift o auto import not working
- java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android : How to make TextView Scrollable
- This class should be public (android.support.v7.internal.widget.ActionBarView.HomeView) Lint Error
- Integrating Android Facebook SDK 3.17.2 Tutorial
- Android R Cannot Be Resolved To A Variable
- Android : Exception raised during rendering: action_bar API 22
- How to take screenshot on Android
- Read Text file from SD Card : Android Programming
- How to make Android EditText not editable
- Your Android SDK is out of date or is missing templates. Please ensure you are using SDK version 22 or later.
- The declared package does not match the expected package Eclipse
- Can't Run SDK Manager find_java.bat issue
- What is Android Toast.LENGTH_SHORT and Toast. LENGTH_LONG durations
- Android Emulator Soft Back button action using Computer keyboard
- Multiline EditText in Android Example
- Use 5G Network on Android Emulator
- Make Android TextView Clickable like Buttons
- How to empty trash in Android Device
- Android : Execute some code after back button is pressed
- Disable Fading Edges Scroll Effect Android Views
- How To Disable Landscape Mode in Android Application
- How to Change Eclipse Default Web Browser - Eclipse
- How to install tabnine on VS Code - HowTos
- How to Center Align Image in Bootstrap - CSS
- Connection Failed: 1130 PHP MySQL Error - MySQL
- Java SE 8 Update 301 available with various bug fixes and security improvements - Java
- Microsoft Teams Error code - 6 issue - Teams
- 11 Weeks of Android Online Sessions-15-Jun-to-28-Aug-2020 - Android
- Increase Android Emulator Timeout time - Android