sash_kp 0 Newbie Poster

Requirement : When i click for the first time on the widget this will redirect to the login page.Once i logged in successfully,from the next time onwards,by clicking on the widget,it should take me to the home page directly without redirecting to the login page again(I want to use intent and shared preferences for this).

I am unable to pass the intent from the widget which is on the home page,to another java file. Here's my take on it when the user launches the widget for the first time:

    public class MyWidgetProvider extends AppWidgetProvider {


  @Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager
                        ,int[] appWidgetIds) {
      super.onUpdate(context, appWidgetManager, appWidgetIds);
          for(int i=0;i<appWidgetIds.length;i++){
          int appWidgetId = appWidgetIds[i];
          SharedPreferences settings = context.getSharedPreferences("MYPREFS",0);
          //Create a pending intent for a widget click
          Intent intent = new Intent(context,TheMainActivity.class);
    //TheMainActivity is the class to which the intent is needed to be sent
              intent.putExtra("logid",settings.getString("logid", ""));
              intent.putExtra("password",settings.getString("password", ""));

    PendingIntent pIntentNetworkInfo = PendingIntent.getActivity(context, 0, 
                        intent, 0);
    RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
                      R.layout.activity_main);
    remoteViews.setOnClickPendingIntent(R.id.update, pIntentNetworkInfo);
    appWidgetManager.updateAppWidget(appWidgetId, remoteViews);

    }
    }


    }

Initially "logid" and "password" are NULL.Hence it will redirect to the login page.But once the user logs in,then from the next time onwards when i run the widget it should automatically redirect to the home page.So let's say

if(logid=="xyz" && password=="abc")

then it should redirect to the home page directly.I am not getting where should i write the code for this purpose(i.e to redirect to another intent showing the home page).Whether it should be written in onUpdate method or onEnabled or which one?
Am a newbie,so please don't whack at me if the explanations are not so good.