"I am developing an Android app in Java and I need to implement a feature where the app checks if the Nearby Share option on the user's device is turned on. When the user clicks a button, a toast message should appear indicating whether Nearby Share is enabled or not. How can I implement this functionality?"
I tried below code segment
private boolean isNearbyShareEnabled() {
ContentResolver contentResolver = getContext().getContentResolver();
int value = Settings.Secure.getInt(contentResolver, "nearby_sharing_state", -1);
return value == 2;
}
Used this code segment inside my Adapter class