Why use Intent.URI_INTENT_SCHEME
Posted
by
hks
on Stack Overflow
See other posts from Stack Overflow
or by hks
Published on 2012-12-03T17:02:15Z
Indexed on
2012/12/03
17:03 UTC
Read the original article
Hit count: 176
android
|android-intent
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?
© Stack Overflow or respective owner