I have created a test Android launcher application and installed it on a rooted device as a system app. The goal is for the app to place all installed widgets on fragments of a viewpager. This has been successfully accomplished; however, the user is shown a message every time a new page is shown.
Even if the user checks the box, the message is still shown every time a widget is to be added.
I have generally followed the steps in Hosting widgets in an android launcher and Adding widgets to a launcher page without bindAppWidgetId() to add widgets to the app.
First I get a list of widgets in the class that extends application and store it in a public static variable
AppWidgetManager manager = AppWidgetManager.getInstance(this);
widgetList = manager.getInstalledProviders();
Next I use a bind intent to get the widget
appWidgetManager = AppWidgetManager.getInstance(this.getActivity());
appWidgetHost = new AppWidgetHost(this.getActivity(), APPWIDGET_HOST_ID);
int id = appWidgetHost.allocateAppWidgetId();
Intent bindIntent = new Intent(AppWidgetManager.ACTION_APPWIDGET_BIND);
bindIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, id);
bindIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_PROVIDER,LauncherExperiment.widgetList.get(mParam1).provider);
startActivityForResult(bindIntent, REQUEST_BIND_APPWIDGET);
Then on activity result I create the widget
Bundle extras = data.getExtras();
int appWidgetId = extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, -1);
AppWidgetProviderInfo appWidgetInfo = appWidgetManager.getAppWidgetInfo(appWidgetId);
AppWidgetHostView hostView = appWidgetHost.createView(this.getActivity(), appWidgetId, appWidgetInfo);
hostView.setAppWidget(appWidgetId, appWidgetInfo);
// Add it on the layout you want
myLayout.addView(hostView);
Again, I have rooted the device and installed the app as a system app by updating the manifest
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.launcherexperiment"
android:sharedUserId="android.uid.system" >
And by following the steps here: How can I sign my application with the system signature key?
So in summary, I have been able to successfully bind apps and display them; but the issue is that the warning message should be displayed at most one time.