Pergunta

How to store/get widget x, y coordinates when the widget created or onEnabled ?? I want to get them because I want to add 2 imageViews net to my widget ImageView here's my code

public class MyWidgetProvider extends AppWidgetProvider {
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    final int N = appWidgetIds.length;

    for (int i=0; i<N; i++) {
        int appWidgetId = appWidgetIds[i];

        Intent intent = new Intent(context, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);

        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
        views.setOnClickPendingIntent(R.id.imageView1, pendingIntent);

        appWidgetManager.updateAppWidget(appWidgetId, views);
    }
}

@Override
public void onEnabled(Context context) {
    // TODO Auto-generated method stub
    super.onEnabled(context);
    Toast.makeText(context, "Welcome to QNotes Application :)", Toast.LENGTH_LONG).show();
}

@Override
public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    super.onReceive(context, intent);
    Toast.makeText(context,"asd", Toast.LENGTH_LONG).show();

}
Foi útil?

Solução

I changed my mind and used transparent activity instead.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top