title: Dynamically adding a custom view to RemoteViews
body: <p>Could any help me to do this? My code is like: </p>
  
  <pre><code> public CustomClass extends View {
  
  //uses ondraw() to do something
  
  }
  </code></pre>
  
  <p>For displaying my custom view on the home screen I created a class to extend Broadcast Receiver:</p>
  
  <pre><code>public class customAppWidgetProvider extends BroadcastReceiver {
  
      public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
  
          if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action)) {
              RemoteViews views = new RemoteViews(context.getPackageName(),
                      R.layout.main);
  
             //Here I want to create my custom view class object and I want to add this view to linear layout in main.xml
  
                CustomClass object = new CustomClass(context) ;
                LinearLayout layout = new LinearLayout(context) ;
                layout.setLayoutParameters(new LayoutParameters(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
                layout.addView(object);
  
              views.addview(R.id.linearlayout, (ViewGroup) layout) ;
              views.setOnClickPendingIntent(R.id.analog_appwidget,
                      PendingIntent.getActivity(context, 0,
                          new Intent(context, AlarmClock.class),
                          PendingIntent.FLAG_CANCEL_CURRENT));
  
              int[] appWidgetIds = intent.getIntArrayExtra(
                      AppWidgetManager.EXTRA_APPWIDGET_IDS);
  
              AppWidgetManager gm = AppWidgetManager.getInstance(context);
              gm.updateAppWidget(appWidgetIds, views);
          }
      }
  }
  </code></pre>
  
  <p>But adding <code>ViewGroup</code> to RemoteView reference is not working... The main.xml layout above contains only LinearLayout. I want to add a custom view object to it. But after running this nothing shows on screen...</p>
  
  <p>Please help me to do this. Thanks in Advance.</p>