I have a question about Android ContentObserver operation

I’m using it to detect a user’s capture by pressing the hardware key.

The function does not work on Galaxy S10+ only (onChange is not called)

All the other devices work, but what’s wrong with him?

Capture related to log is as follows.

E/[ScrCap]_RemoteScrollCaptureInterface (18018): isPackageAvailable : not available. e=android.content.pm.PackageManager$NameNotFoundException: com.samsung co., ltd.android.app.scrollcapture

D/[SmartCapture]_SmartCaptureUtils (18080): isNavigationBarMovable Exception: java.lang.NoSuchMethodException: android.view.IWindowManager$Stub$Proxy.isNavBarCan Move]

E/[SmartCapture]_ScrollCaptureUtils (18080): isPackageAvailable : com.samsung co., ltd.android.service.tagService is not available. e=android.content.pmPackageManager$NameNotFoundException: com.samsung co., ltd.android.service.tagservice

Is there a special issue in Galaxy S10+?

MyCode:

if (contentObserver == null)
{
    HandlerThread handlerThread = new HandlerThread("contentobserver"
    handlerThread.start();

    final Handler handler = new Handler(handlerThread.getLooper())
    {
        @Override
        public void handleMessage(Message msg)
        {
            super.handleMessage(msg);
        }
    };

    contentObserver = new ContentObserver(handler)
    {
        @Override
        public boolean deliverSelfNotifications()
        {                    
            return super.deliverSelfNotifications();
        }

        @Override
        public void onChange(boolean selfChange)
        {
            super.onChange(selfChange);
        }

        @Override
        public void onChange(boolean selfChange, Uri uri)
        {
            super.onChange(selfChange, uri);
        }
    };
}

getContentResolver().registerContentObserver(
        MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
        false,
        contentObserver);

Devices : SM-G975N
Android Version : 10

Have you tried it on non samsung devices?

It’s possible that there could be a specific behavior or configuration on the Galaxy S10+ that is causing the ContentObserver to not work as expected. Here are a few things you can check or try:

  1. Permissions

Ensure that your app has the necessary permissions to listen for changes you’re interested in. For example, if you’re trying to detect changes in the camera, your app should have the android.permission.CAMERA permission.

  1. Content URI

Make sure you’re registering your ContentObserver with the correct content URI. Depending on the specific feature you’re trying to observe (e.g., capturing an image), you might need to register for changes in a specific URI related to the camera or media storage.

  1. Testing on Multiple S10+ Devices

If possible, try testing your app on multiple Galaxy S10+ devices to see if the issue is consistent across all of them. This can help determine if the problem is specific to your device or if it’s a more general issue.

  1. Device-specific Behavior

Some devices may have customized behaviors or restrictions that could affect the behavior of ContentObservers. Check the documentation or forums specific to the Galaxy S10+ to see if there are any known issues or quirks related to ContentObservers or capturing events.

  1. Testing with Different Event Types

Experiment with registering your ContentObserver for different types of events (e.g., TYPE_INSERT, TYPE_UPDATE, TYPE_DELETE) to see if any of them trigger the onChange method on the Galaxy S10+.

  1. Testing with Other Observers

Try registering your ContentObserver to observe changes in different types of data (e.g., contacts, calendar events) to see if the issue is specific to the camera-related changes or if it affects all ContentObservers on the device.

  1. Testing with Different Android Versions

If possible, test your app on different versions of Android running on the Galaxy S10+ to see if the behavior changes.

  1. Logging and Debugging

Use logging statements or a debugger to trace the execution of your ContentObserver and see if there are any errors or unexpected behaviors occurring on the Galaxy S10+ device.

By systematically checking these points, you may be able to identify the root cause of the issue and find a solution that works on the Galaxy S10+ device. Collaboration with other developers, testing, and user feedback play significant roles in the success of Android development projects.

– link removed –