title: How does an android activity interact with app-widget (Home screen widgets)?
body: <p>If I have an activity, so how can I use some of its methods (functionalities) in android widgets. Do I have to recreate the logic? What are the ways of interaction? Through intent or through service? Please please reply.  </p>
  
  <p>Update: I have a .java class that implements Parcelable and contains the method that returns the list. I want that list in my widget.</p>
  
  <pre><code>public Stores getStoreListings() {
          Log.i("List val","mStoreListings");
          return mStoreListings;
      } 
  </code></pre>
  
  <p>Can I use Intent in my app widget to get this method or variable? This is not an activity.. </p>
  
  <hr>
  
  <p>UPDATE2: Using Async task, its not working also..Where I am going wrong?? PLease help..</p>
  
  <pre><code>public class ListViewWidget extends AppWidgetProvider{
  
      @Override
      public void onUpdate(Context context,AppWidgetManager appWidgetManager, int []appWidgetIds){
          super.onUpdate(context, appWidgetManager, appWidgetIds);
          RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.list_layout);
          ComponentName thisWidget = new ComponentName(context,ListViewWidget.class);
  
          String url=String.valueOf("https://api.paypal.com/v1/stores?view=local&amp;lat=37.3756096&amp;lng=-121.9239449&amp;radius=50&amp;count=20&amp;start_id=1&amp;country_code=US");
  
          FetchTask fetchTask=new FetchTask();
          //fetchTask.appWidgetManager=appWidgetManager;
          //fetchTask.onPostExecute(updateViews,context);
          fetchTask.execute();
          //context.startService(new Intent(context,UpdateService.class));
      }
      public static class FetchTask extends AsyncTask&lt;URL,Integer,Stores&gt;{
  
          String text=null;
          @Override
          protected Stores doInBackground(URL... arg0) {
              // TODO Auto-generated method stub
              HttpClient httpClient=new DefaultHttpClient();
              HttpContext localContext=new BasicHttpContext();
              HttpGet httpGet=new HttpGet("https://api.paypal.com/v1/stores?view=local&amp;lat=37.3756096&amp;lng=-121.9239449&amp;radius=50&amp;count=20&amp;start_id=1&amp;country_code=US");
  
              Stores newList=new Stores();
              try{
  
                  HttpResponse response=httpClient.execute(httpGet,localContext);
                  HttpEntity entity=response.getEntity();
                  text=String.valueOf(entity);
  
  
                  //assign the list to the the correct entity type
                  //newList=..;
                  Log.i("Inside on update with Http call","Text"+text);
              }
              catch(Exception e){
                  e.printStackTrace();
              }
  
  
              return newList;
          }
  
          protected void onPostExecute(RemoteViews updateViews,Context context){
  
              Intent intent=new Intent("android.appwidget.action.APPWIDGET_UPDATE");
  
              PendingIntent pendingIntent=PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
              updateViews.setTextViewText(R.id.text_view, text);
              updateViews.setOnClickPendingIntent(R.id.next, pendingIntent);
  
              // Push update for this widget to the home screen
              ComponentName thisWidget = new ComponentName(this, ListViewWidget.class);
              AppWidgetManager manager = AppWidgetManager.getInstance(this);
              manager.updateAppWidget(thisWidget, updateViews);
          }
  
      }
  }
  </code></pre>