title: setData on RemoteViewService intents
body: <p>What is the use of </p>
  
  <pre><code>serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
  </code></pre>
  
  <p>on the following <code>Intent</code> in an AppWidgetProvider class (see code below)</p>
  
  <p>According to the CommonsWare book, the reason is:</p>
  
  <blockquote>
    <p>While your application has access to your RemoteViewsService Class object, the app widget host will not, and so we need something that will work across process boundaries. You could elect to add your own  to the RemoteViewsService and use an Intent based on that, but that would make your service more publicly visible than you might want. </p>
  </blockquote>
  
  <p>Source: The Busy Coder's Guide to Android Development
  <a href="https://commonsware.com/Android/" rel="nofollow noreferrer">https://commonsware.com/Android/</a></p>
  
  <p>But when I delete this line, nothing changes. The widget still works.</p>
  
  <pre><code>@Override
  public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
      for (int appWidgetId : appWidgetIds) {
  
          [...]
  
          Intent serviceIntent = new Intent(context, WidgetService.class);
          serviceIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
          serviceIntent.setData(Uri.parse(serviceIntent.toUri(Intent.URI_INTENT_SCHEME)));
  
          views.setRemoteAdapter(R.id.stack_view, serviceIntent);
          views.setEmptyView(R.id.stack_view, R.id.empty_view);
  
          [...]
  
          appWidgetManager.updateAppWidget(appWidgetId, views);
      }
  </code></pre>