title: Screenshot does not take the latest, current or updated view (Android)
body: <p>I'm trying to switch a banner adView to imageView just before I take a screenshot so that users can share this screenshot through share intent.
  However, when I take the screenshot, it does not include the imageView.</p>
  
  <pre><code>public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ....
    adView1 = new AdView(this, AdSize.BANNER, MY_AD_UNIT_ID1);
    LinearLayout.LayoutParams childParam2 = new    
    LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 0.10f);
    adView1.setLayoutParams(childParam2);
    adView1.loadAd(new AdRequest());
    ll.addView(adView1);
    setContentView(ll);
  
  
    myAdView = new ImageView(this);
    LinearLayout.LayoutParams childParam1 = new    
         LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 0.10f);
    myAdView.setLayoutParams(childParam1);
  
    ....
    View.OnClickListener handler = new  View.OnClickListener() {
          public void onClick(View v) {
               switch (v.getId()) {
                         ...
                         case R.id.menu3:
                             share();
                             break;
                         ...
                       }
   }
  </code></pre>
  
  <p>Here's share() function.</p>
  
  <pre><code>private void share(){
      List&lt;Intent&gt; targetedShareIntents = new ArrayList&lt;Intent&gt;();
      Intent intent = new Intent(Intent.ACTION_SEND);
      intent.setType("*/*");
      List&lt;ResolveInfo&gt; resInfo =     
                   this.getPackageManager().queryIntentActivities(intent, 0);
  
      for (ResolveInfo resolveInfo : resInfo) {
              ........
  
                  if (packageName.toLowerCase().contains("twitter")){
  
                    targetedShareIntent.setType("*/*");
                    String location = "file://" + takeScreen(ll);
                     ...
                   }
              ...
      }
  </code></pre>
  
  <p>This is  takeScreen(View v) function.</p>
  
  <pre><code>public String takeScreen(View c_view){
       ll.removeView(adView1);
       ll.addView(myAdView);
  
      // create bitmap screen capture
      Bitmap bitmap;
      View v1 = c_view.getRootView();
      v1.setDrawingCacheEnabled(true);
      bitmap = v1.getDrawingCache();
  
      String extr = Environment.getExternalStorageDirectory().toString();
      File imageFile = new File(extr,  "screen_" + System.currentTimeMillis() + ".jpg");
  
      OutputStream fout = null;
  
      try {
          fout = new FileOutputStream(imageFile);
          boolean saved = bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fout);
          //Log.e("bitmap saved ?", saved + "!");
          fout.flush();
          fout.close();
          MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "Screen", "screen");
  
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  
      ll.removeView(myAdView);
      ll.addView(adView1);
      return imageFile.getPath();
  }
  </code></pre>
  
  <p>As you can see, I'm removing adView and adding myAdView(imageView) just before the screenshot is taken in takeScreen() function. adView IS removed but imageVies is NOT added to the screenshot. </p>
  
  <p>The imageView DOES appear on the screen just before chooserIntent(share intent) pop-up screen is displayed.</p>
  
  <p>I have tried many other options like</p>
  
  <ul>
  <li>added both views and just switched visibility. setVisibility(View.Gone, View.Visible)</li>
  <li>tried creating bitmap with canvas instead of getDrawingCache (thinking that it could be a cache related problem)</li>
  </ul>
  
  <p>Is taking screenshot or 'share intent' too much of work for the UI thread to be blocked?
  Can anyone shed a light here? I am completely at a loss.</p>