App Widget Half 2 – CONFIGURATION ACTIVITY – Android Studio Tutorial

Partly 2 of the app widget tutorial, we add a configuration exercise to our app, which begins when our widget is dragged onto the homescreen and the place we are able to do an preliminary setup. We get our appWidgetId from the intent with the AppWidgetManager.EXTRA_APPWIDGET_ID key and might then make adjustments to this widget with assist of the RemoteViews class. We are going to give the consumer the choice to set his personal button textual content and as within the final video we set a PendingIntent to our button which can open our MainActivity when clicked. We may also save the button textual content to SharedPreferences after which end our exercise with RESULT_OK and go the appWidgetId again. In case we do not get handed a sound id, our appWidgetId shall be set to AppWidgetManager.INVALID_APPWIDGET_ID.
In our AppWidgetProvider class we retrieve the button textual content from shared preferences in our onUpdate technique and reset it along with the pending intent to our button.
In our AndroidManifest.xml file we’ve got to set the android.appwidget.motion.APPWIDGET_CONFIGURE intent filter for our config exercise and within the data xml file we’ve got so as to add the android:configure attribute.

Watch the entire playlist:

Instance code:

❗ Subscribe to the channel:

🎓 Discover extra tutorials and programs on my web site:

💻 Rent me to your subsequent venture:

📨 Subscribe to the Coding in Move e-newsletter:

💚 Donate to Coding in Move with a message:

❓ Ask your programming questions in our chat:

📣 Comply with Coding in Move on different websites:

⌨️ My gear and instruments:
Display screen recorder:

(above hyperlinks are affiliate hyperlinks, which signifies that I earn a small fee if you happen to purchase by way of them with NO further prices to you.)