0

I created a widget app and it works perfectly. Now i need to show a toast message while clicking on widget. Is it possible i tried with below code.

public void updateView(Context context) {  
     RemoteViews thisViews = new RemoteViews(context.getApplicationContext().getPackageName(), R.layout.widget_layout);
     thisViews.setOnClickPendingIntent(R.id.relativeLayout1, actionPendingIntent(context));
     thisViews.setTextViewText(R.id.widget_text, batteryLevel);  
     thisViews.setImageViewResource(R.id.imageView1, widgetImageFrame);  
     ComponentName thisWidget = new ComponentName(context, BatteryStatusWidgetActivity.class);  
     AppWidgetManager.getInstance(context).updateAppWidget(thisWidget, thisViews);  
}  

public static PendingIntent actionPendingIntent(Context context) {
        Intent intent = new Intent(context,LaunchActivity.class);
        intent.setAction("LAUNCH_ACTIVITY");
    return PendingIntent.getActivity(context, 0, intent,    PendingIntent.FLAG_UPDATE_CURRENT);
    }

The above sample will launch an activity, but i need just a toast message.

thanks in advance

Riskhan
  • 4,434
  • 12
  • 50
  • 76

0 Answers0