Enable Widget Setting button for widgets in Android?
Samsung One UI Home Screen shows a setting button for some widgets when I select the widget,
But not for some
Wondering what is the difference between the two or is it just a OEM specific feature as I couldn't the menu in POCO launcher or emulator's launcher at all.
Please note I am already using
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:configure=".WidgetConfigurationActivity"
...
in my provider and this in my manifest
<receiver ...>
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
...
Yet these are just adding configuration when I add a widget not after the addition of the widget, and couldn't find the answer on searching the net.
Solution 1:
I know this question is months old, but I'll answer anyway. After reverse-engineering a Samsung app, I've found the secret behind the Settings button.
You only got to add this meta-data to your app widget (<receiver>
):
<meta-data android:name="android.appwidget.provider.semConfigureActivity" android:value="com.example.MySettingsActivity" />
Full example:
<receiver android:name="com.example.MyWidget">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE"/>
</intent-filter>
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_info"/>
<!-- The secret sauce is here -->
<meta-data android:name="android.appwidget.provider.semConfigureActivity" android:value="com.example.MySettings"/>
</receiver>
Advice: It's recommended to learn reverse-engineering to implement undocumented features (just make sure the core functionality of your app does not depend on undocumented APIs).