Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding AppWidgets to AppWidgetHost - Android

When you normally want to add an AppWidget in Android there is a list where you need to pick one widget and it binds it to the home screen.

I'm trying to build an app which has its own appWidgetHost and specific App Widgets that I built for it.

I have two problems:

  1. I would like to be able to automatically bind a widget to my AppWidgetsHost without the user picking from the list.
  2. I want to make my own 'pick widgets list' and to load only widgets that I have created.

To make it simple; There is my app with my AppWidgets and I want full control in terms of binding a appWidget to the appWidgetHost etc.

3 people asked similar questions in Google forums:

  1. Link 1
  2. Link 2
  3. Link 3

The only answer I found to be a possibility is in link number 2. Paraneet (one of the repliers) said that you can install the app under /system/app instead of /data/app because some security issue. but I'm not sure if it is a reliable solution for production, and I would like to know more about the pros and cons of doing this.

Thanks, Shai.

like image 223
shaimagz Avatar asked Nov 23 '10 16:11

shaimagz


2 Answers

Unfortunatlly for you (and me), Paraneet is right.

binding appwidget is a sensitive action and thus, to avoid malware it requires the user's consent for the most part however if you install your app into the /system/data folder then you considered part of the OS and you are given a system permission which lets you decide to bind appwidget that you created without any user's involvement.

like image 73
Royi Benyossef Avatar answered Sep 29 '22 04:09

Royi Benyossef


In Android O, its possible to pin app widget programmatically. Just watch at example here

Also check out Google official documentation

like image 31
HeyAlex Avatar answered Sep 29 '22 06:09

HeyAlex