Reputation: 4187
I'm using this method:
Future<void> _requestToPinWidget() async {
final isRequestPinSupported =
await HomeWidget.isRequestPinWidgetSupported();
if (isRequestPinSupported == true) {
await HomeWidget.requestPinWidget(
androidName: 'HomeScreenWidgetProvider',
qualifiedAndroidName:
'com.example.porftolio_investments.HomeScreenWidgetProvider',
);
}
}
The first time, it asks for permissions correctly, but nothing happens after accepting or the next time I click the button.
If I specify a different androidName
, it fails. Since I use Flutter, I'm not sure how to test this further. I added a try/catch in this method, and it works "fine", so I assume the problem comes from the native part.
The AndroidManifest.xml seems correct:
<receiver
android:name="HomeScreenWidgetProvider"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget_info" />
</receiver>
<!-- home screen widget -->
<!-- HomeWidget background receiver -->
<receiver
android:name="es.antonborri.home_widget.HomeWidgetBackgroundReceiver"
android:exported="true">
<intent-filter>
<action android:name="es.antonborri.home_widget.action.BACKGROUND" />
</intent-filter>
</receiver>
<!-- HomeWidget background service -->
<service
android:name="es.antonborri.home_widget.HomeWidgetBackgroundService"
android:permission="android.permission.BIND_JOB_SERVICE"
android:exported="true" />
The Flutter package is this one: https://pub.dev/packages/home_widget
Upvotes: 0
Views: 62
Reputation: 4187
After making some space in my home screen, the widget appears correctly
Upvotes: 0