How do I give a Android App Widget a Label/Name-ThrowExceptions

Exception or error:

I just finished my first app, it works fine and I’ve made it a homescreen widget. But it doesn’t have the name under it. The tutorial I am following says nothing about it, shouldn’t this just be the name of the app and be pulled in automatically?

How to solve:

You can set the name of your app widget to be displayed in the widget picker by adding android:label="the name of my appwidget" to the receiver that handles appwidget related intents in AndroidManifest.xml. It is documented in a somewhat obscure place: http://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo.html#label

Example of use in AndroidManifest.xml:

<receiver android:name=".widget.MyWidgetProvider" android:label="My App Widget">
   ...
</receiver>

Note: this property was deprecated in API 21, but still works as of API 29.

###

You can set it in the AndroidManifest.xml. App Widgets might be of some help.

Leave a Reply

Your email address will not be published. Required fields are marked *