title: Widget click calls a method on a dead Activity
body: <p>I have a widget that when I click it, I want to create an SMS and open the Default Text Message app. I have the second part (sms creation -&gt; intent, startactivity open Default sms app), but i cant figure out the first part.</p>
  <p>onUpdate @ the widgetProvider class</p>
  <pre><code>@Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
      // There may be multiple widgets active, so update all of them
      for (int appWidgetId : appWidgetIds) {
          RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.sms_widget);
          views.setOnClickPendingIntent(R.id.docButton, getPendingSelfIntent(context, SMS1));
          views.setOnClickPendingIntent(R.id.shopButton, getPendingSelfIntent(context, SMS2));
          views.setOnClickPendingIntent(R.id.bankButton, getPendingSelfIntent(context, SMS3));
          views.setOnClickPendingIntent(R.id.helpButton, getPendingSelfIntent(context, SMS4));
          views.setOnClickPendingIntent(R.id.familyButton, getPendingSelfIntent(context, SMS5));
          views.setOnClickPendingIntent(R.id.runButton, getPendingSelfIntent(context, SMS6));
          ComponentName watchWidget = new ComponentName(context, smsWidget.class);
          appWidgetManager.updateAppWidget(watchWidget, views);
      }
  }
  
  @Override
  public void onReceive(Context context, Intent intent) {
      SmsHelper smsHelper = SmsHelper.getInstance();
      Log.d(&quot;widget&quot;, &quot;on receive 1&quot;);
      User user= PreferencesManager.getObject(&quot;user&quot;, User.class);
      super.onReceive(context, intent);
  
      if(SMS1.equals(intent.getAction())){
          AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
          RemoteViews remoteViews;
          ComponentName watchWidget;
          remoteViews = new RemoteViews(context.getPackageName(), R.layout.sms_widget);
          watchWidget = new ComponentName(context, smsWidget.class);
          appWidgetManager.updateAppWidget(watchWidget, remoteViews);
          smsHelper.sendSms(PHONE_NUMBER, &quot;1 &quot; + user.getFullName() + &quot; &quot; + user.getAddress());
  
      }
  </code></pre>
  <p>This is happening in the app widget provider but in order to start the default text message app i need to start it from an activity which is dead at the moment. `public class SmsHelper {</p>
  <pre><code>private static SmsHelper INSTANCE;
  
  private SmsHelper(){
  
  }
  
  public static SmsHelper getInstance(){
      synchronized (SmsHelper.class){
          if (INSTANCE == null){
              INSTANCE = new SmsHelper();
          }
      }
      return INSTANCE;
  }
  
  public void sendSms(String phoneNumber, String message) {
      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(&quot;sms:&quot; + phoneNumber));
      intent.putExtra(&quot;sms_body&quot;, message);
      startActivity(intent);
  }}`
  </code></pre>
  <p>The last line ofc is not working, as i get a NPE at ActivityThreadApplicationThread</p>