title: Can't launch ActivityManager.RunningTaskInfo.topActivity from Android AppWidgetProvider
body: <p>I have onUpdate(...) metod of MyAppWidgetProvider class with the code:</p>
  
  <pre><code>...
  Intent launchAppIntent = new Intent(context, SearchActivity.class);        
  PendingIntent launchAppPendingIntent = PendingIntent.getActivity(context, 0, launchAppIntent, 0);        
  remoteView.setOnClickPendingIntent(R.id.logo, launchAppPendingIntent);  
  ...
  </code></pre>
  
  <p>It works fine. New SearchActivity starts by clicking on widget. Now, I want to start on click not the SearchActivity, but an activity from the top of the stack of my task. For this purpose I change above code to:</p>
  
  <pre><code>ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
  List&lt;ActivityManager.RunningTaskInfo&gt; tasks = am.getRunningTasks(30);        
  for (ActivityManager.RunningTaskInfo task:tasks) {
      if (task.baseActivity.getShortClassName().equals(".MainActivity")) {    
          try {
              Intent launchAppIntent = new Intent(context, Class.forName(task.topActivity.getClassName()));
              PendingIntent launchAppPendingIntent = PendingIntent.getActivity(context, 0, launchAppIntent, 0);        
              remoteView.setOnClickPendingIntent(R.id.logo, launchAppPendingIntent);                     
          } catch (ClassNotFoundException ex) {
              Logger.getLogger(CashWidgetProvider.class.getName()).log(Level.SEVERE, null, ex);
          }                  
      }
  }
  </code></pre>
  
  <p>that doesn't work. Foreground activity in task stack doesn't appear on monitor. Moreover, I don't get any messages in log running this code.</p>
  
  <p>However, the same code works fine being placed in some method of the class, inherited from Activity. </p>
  
  <pre><code>ActivityManager am = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE);
  List&lt;ActivityManager.RunningTaskInfo&gt; tasks = am.getRunningTasks(30);        
  for (ActivityManager.RunningTaskInfo task:tasks) {
      System.out.println(task.baseActivity.getShortClassName());
      if (task.baseActivity.getShortClassName().equals(".MainActivity")) {
          try {
              Intent launchAppIntent = new Intent(this, Class.forName(task.topActivity.getClassName())); 
              startActivity(launchAppIntent);
          } catch (ClassNotFoundException ex) {
              Logger.getLogger(AbstractActivity.class.getName()).log(Level.SEVERE, null, ex);
          }
      }
  } 
  </code></pre>
  
  <p>How can I get it working for AppWidget!?</p>