Android Question multiple widget with different layouts

leitor79

Active Member
Licensed User
Longtime User
Hi,

I'm tunning this superb corwin's example, but I need my two layouts to have different default sizes. I'd rather not to have two services nor two configuration screens because the behavior will be the same for both.

So:

1) I needed to add some stuff to see the 2 kind of widgets on the widget list. I've managed to do that by following this tutorial, with some kind of success (I manage to see the 2 widgets layouts in the preview screen).

I added this code to the manifest editor:

B4X:
AddApplicationText(<receiver
            android:name=".advancedwidgetlarge$advancedwidgetlarge_BR"
            android:label="Countator Large">
            <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            </intent-filter>
            <meta-data android:name="android.appwidget.provider"
            android:resource="@xml/advancedwidget_infolarge" />
           
        </receiver>)

I've added an empty service (just the default stuff) named "advancedwidgetlarge" beucause it throws me an error otherwise.

I've added the new xml files (infolarge), and the drawable.

Thus far I see the 2 widgets, I add both of them OK, but the "new" one, even if it's visible after adding it to the home screen, it "brokes" after reinitializing. It keeps showing the "init" layout; I think that's due to the reference to the empty service.

2) I also like to set up something (and intent?) to detect at widgetconfig creation, to show the normal or the large layout in the preview according to the widget the user dragged. So I suppose I need to add something to the manifest editor or to the large_info.xml file, but I'cant figure what or where. I'd like to use the same activity for configuration since both widgets has the same properties an behavior.

Thank you very much!
 
Top