I'm having a permission problem that has slipped a bit from my knowledge. Inside a widget I inserted a button, which when pressing I get the following message:
04-13 14: 10: 44.340: E / DatabaseUtils (2362): java.lang.SecurityException: Permission Denial: get / set setting for user asks to run user -2 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL
04-13 14: 28: 19,370: E / DatabaseUtils (2362): at com.android.server.am.ActivityManagerService.handleIncomingUser (ActivityManagerService.java:13140)
04-13 14: 28: 19.370: E / DatabaseUtils (2362): at android.app.ActivityManager.handleIncomingUser (ActivityManager.java:2038)
04-13 14: 28: 19.370: E / DatabaseUtils (2362): at com.android.providers.settings.SettingsProvider.callFromPackage (SettingsProvider.java:607)
04-13 14: 28: 19.370: E / DatabaseUtils (2362): at android.content.ContentProvider $ Transport.call (ContentProvider.java:279)
04-13 14: 28: 19,370: E / DatabaseUtils (2362): at android.content.ContentProviderNative.onTransact (ContentProviderNative.java:273)
04-13 14: 28: 19,370: E / DatabaseUtils (2362): at android.os.Binder.execTransact (Binder.java:388)
04-13 14: 28: 19,370: E / DatabaseUtils (2362): at dalvik.system.NativeStart.run (Native Method)
04-13 14: 28: 19,570: E / EnterpriseContainerManager (2362): ContainerPolicy Service is not yet ready !!!
It works as follows: In the WidgetApp class, in the onUpdate () method I have the following lines ( lines in question ):
rv = new RemoteViews(context.getPackageName(),R.layout.widget_layout);
Intent intentSync = new Intent(context, Sincroniza.class);
PendingIntent piS = PendingIntent.getActivity(context, 0, intentSync, 0);
rv.setOnClickPendingIntent(R.id.widget_Btn_Atualiza, piS);
In Activity Sync I have the following lines in the onCreate () method:
this.runOnUiThread(new Runnable() {
@Override
public void run() {
Intent intentService = new Intent(getApplicationContext(), AWidget.class);
startService(intentService);
Toast.makeText(getApplicationContext(), "Widget Atualizado!", Toast.LENGTH_LONG).show();
}
});
finish();
That is, on the lines above: load Activity, make the service call and close. For those who work with Widget, you know that setOnClickPendingIntent () needs to be called a PendingIntent.
On the INTERACT_ACROSS_USERS_FULL permission, it's no use putting the uses permissions, which does not even stay on the standard sdk list, you have to enter manual. Secondly, that's no use.
In short, my widget (which is based on BroadcastReceiver by default for Android) loads a RemoteViews layout and inserts a desired button event (setOnClickPendingIntent). This event loads an Activity, which executes a Service, and then closes the same Activity.
INTERESTING: All this works normal for a period, after a few minutes to work.
DETAIL: The Service class AWidget.class uses in an AlarmManager and works without problems.