Thanks
Richard for your reply. It solved my problem partially. Now when I move the widget on the home screen toast message is shown but when I click on the button nothing shown. But I want to show a toast message
(or turn on Bluetooth as per requirements).
The updated version of ToggleBluetooth.java file is:
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
Log.d(TAG, "onUpdate()");
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++) {
Intent intent = new Intent(context, BluetoothToggle.class);
intent.setAction(toggleBluetoothAction);
PendingIntent pendingIntent = PendingIntent.getService(context, 0, intent, 0);
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.bluetooth_toggle);
remoteViews.setOnClickPendingIntent(R.id.btnToggleBluetooth, pendingIntent);
updateAppWidget(context, appWidgetManager, appWidgetIds[i]);
}
}
..... other methods same as in questions
@Override
public void onReceive(Context context, Intent intent) {
super.onReceive(context, intent);
Log.d(TAG, "onReceive");
Log.d(TAG, intent.getAction());
Toast.makeText(context, "Button Clicked.....!!!", Toast.LENGTH_SHORT).show();
}