Why use Intent.URI_INTENT_SCHEME
- by hks
while reading Android docs about Widgets I stumbled upon this piece of code whose purpose is to launch a service for retrieving a factory for StackView items.
// Set up the intent that starts the StackViewService, which will
// provide the views for this collection.
Intent intent = new Intent(context, StackWidgetService.class);
// Add the app widget ID to the intent extras.
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
// Instantiate the RemoteViews object for the App Widget layout.
RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
// Set up the RemoteViews object to use a RemoteViews adapter.
// This adapter connects
// to a RemoteViewsService through the specified intent.
// This is how you populate the data.
rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);
You can find it here
I have a problem understanding why do you need to call
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
I understand that it gives URI a prefix intent://, but is it necessary here?