I couldnt find anywhere a case that a widget launches a dialog box when it is clicked. Do you have any ideas?
I have this code
public void onUpdate(Context c, AppWidgetManager appWidgetManager,int[] appWidgetIds) {
final int N = appWidgetIds.length;
AppWidgetManager mgr = AppWidgetManager.getInstance(c);
for (int i=0; i<N; i++) {
int appWidgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(c.getPackageName(), R.layout.widget_layout);
Intent fireDialog = new Intent(c,Execute.class);
Toast test=Toast.makeText(c.getApplicationContext(),"onUpdate",Toast.LENGTH_LONG);
test.show();
PendingIntent pendingIntent = PendingIntent.getActivity(c, appWidgetId, fireDialog, PendingIntent.FLAG_UPDATE_CURRENT);
views.setOnClickPendingIntent(R.id.Button, pendingIntent);
Log.w(LOG_TAG,"Called");
mgr.updateAppWidget(appWidgetId, views);
}
}
I am assuming here that by "widget" you mean "app widget", the interactive elements an application can add to the user's home screen.
An app widget cannot display a Dialog
, as that can only be done by an Activity
. Your app widget can start up an Activity
, though, via startActivity()
. And, you can theme your activity to look like a dialog, by adding android:theme="@android:style/Theme.Dialog"
to your element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With