i am learning how to create a widget but i am stuck at this point. i have a widget that contains a button that when clicked, will launch an activity. but there are two activities that may launch and this depends on a Boolean value. the Boolean Value is true if the current Activity is MainActivity, and is false otherwise. but when clicking the button, it seems that the boolean value doesn't update to its new value here. am i doing something wrong. any help would be appreciaited.
public void onUpdate(final Context context, final AppWidgetManager appWidgetManager, final int[] appWidgetIds)
{
final int N = appWidgetIds.length;
for (int i = 0; i < N; i++)
{
final int appWidgetId = appWidgetIds[i];
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.rz_widget_layout);
Intent intent=null;
if(MainActivity.WidgetAppLuancherChecker){intent= new Intent(context, MainActivity.class);}
else{intent= new Intent(context, ActivityB.class);}
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
views.setOnClickPendingIntent(R.id.LaunchApp, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
Manifest
<receiver android:name="com.AppWidget.ApWidgetProvider" >
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/info_widget_layout" />
</receiver>