Intent i = new Intent(); i.setAction("com.bubblebeats.MY_CUSTOM_ACTION"); i.putExtra("some_variable", "123456"); Log.d("ezpz", i.toUri(Intent.URI_INTENT_SCHEME));
Intent intent = new Intent(context, Settings.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appId); // Identifies the particular widget... intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // Make the pending intent unique... intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); PendingIntent pendIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.wwwidget); views.setOnClickPendingIntent(R.id.widget, pendIntent); appWidgetManager.updateAppWidget(appId,views);
private void handleUninstallShortcutIntent(Intent intent) { Intent shortcut = intent.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); if (shortcut != null) { ComponentName componentName = shortcut.resolveActivity(getPM()); if (componentName != null) { Intent newShortcutIntent = new Intent(); newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0)); newShortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME); newShortcutIntent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, newShortcutIntent); } } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView uri=(TextView)findViewById(R.id.uri); if (Intent.ACTION_MAIN.equals(getIntent().getAction())) { String intentUri=(new Intent("com.commonsware.android.MY_ACTION")) .toUri(Intent.URI_INTENT_SCHEME) .toString(); uri.setText(intentUri); Log.w("URLHandler", intentUri); } else { Uri data=getIntent().getData(); if (data==null) { uri.setText("Got com.commonsware.android.MY_ACTION Intent"); } else { uri.setText(getIntent().getData().toString()); } } }
@Override public void onUpdate(Context ctxt, AppWidgetManager appWidgetManager, int[] appWidgetIds) { for (int i=0; i<appWidgetIds.length; i++) { Intent svcIntent=new Intent(ctxt, WidgetService.class); svcIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]); svcIntent.setData(Uri.parse(svcIntent.toUri(Intent.URI_INTENT_SCHEME))); RemoteViews widget=new RemoteViews(ctxt.getPackageName(), R.layout.widget); widget.setRemoteAdapter(R.id.words, svcIntent); Intent clickIntent=new Intent(ctxt, LoremActivity.class); PendingIntent clickPI=PendingIntent .getActivity(ctxt, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT); widget.setPendingIntentTemplate(R.id.words, clickPI); appWidgetManager.updateAppWidget(appWidgetIds[i], widget); } super.onUpdate(ctxt, appWidgetManager, appWidgetIds); } }
newShortcutIntent.addCategory(Intent.CATEGORY_DEFAULT); newShortcutIntent.putExtra("_VA_|_intent_", shortcut); newShortcutIntent.putExtra("_VA_|_uri_", shortcut.toUri(0)); newShortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId()); intent.removeExtra(Intent.EXTRA_SHORTCUT_INTENT);
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void updateCollection(int appWidgetId, RemoteViews remoteViews, WidgetConfig config) { remoteViews.setTextViewText(R.id.subtitle, DateUtils.formatDateTime(mContext, System.currentTimeMillis(), DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME)); remoteViews.setOnClickPendingIntent(R.id.button_refresh, createRefreshPendingIntent(appWidgetId)); Intent intent = new Intent(mContext, WidgetService.class) .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId) .putExtra(WidgetService.EXTRA_CUSTOM_QUERY, config.customQuery) .putExtra(WidgetService.EXTRA_SECTION, config.section) .putExtra(WidgetService.EXTRA_LIGHT_THEME, config.isLightTheme); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { remoteViews.setRemoteAdapter(android.R.id.list, intent); } else { //noinspection deprecation remoteViews.setRemoteAdapter(appWidgetId, android.R.id.list, intent); } remoteViews.setEmptyView(android.R.id.list, R.id.empty); remoteViews.setPendingIntentTemplate(android.R.id.list, PendingIntent.getActivity(mContext, 0, new Intent(Intent.ACTION_VIEW), 0)); }
return intent.toUri(Intent.URI_INTENT_SCHEME);
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) { RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.message_list_widget_layout); views.setTextViewText(R.id.folder, context.getString(R.string.integrated_inbox_title)); Intent intent = new Intent(context, MessageListWidgetService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME))); views.setRemoteAdapter(R.id.listView, intent); PendingIntent viewAction = viewActionTemplatePendingIntent(context); views.setPendingIntentTemplate(R.id.listView, viewAction); PendingIntent composeAction = composeActionPendingIntent(context); views.setOnClickPendingIntent(R.id.new_message, composeAction); PendingIntent headerClickAction = viewUnifiedInboxPendingIntent(context); views.setOnClickPendingIntent(R.id.top_controls, headerClickAction); appWidgetManager.updateAppWidget(appWidgetId, views); }
private JSONObject dumpContent(JSONObject json) throws JSONException { JSONObject extras=new JSONObject(); if (content.getExtras()!=null) { json.put("extras", extras); dumpBundle(content.getExtras(), extras); } if (content.getIntent()!=null) { json.put("intent", content.getIntent().toUri(Intent.URI_INTENT_SCHEME)); } json.put("structuredData", wrap(content.getStructuredData())); json.put("webUri", wrap(content.getWebUri())); return (json); }
shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT); persistableBundle.putString("_VA_|_uri_", intent.toUri(0)); persistableBundle.putInt("_VA_|_user_id_", 0); swap[i] = shortcutIntent;
/** * Serializes this {@link Action} object to a {@link android.os.Bundle} representation. */ public Bundle toBundle() { Bundle bundle = new Bundle(); bundle.putString(KEY_TITLE, mTitle); bundle.putString(KEY_VIEW_INTENT, (mViewIntent != null) ? mViewIntent.toUri(Intent.URI_INTENT_SCHEME) : null); bundle.putInt(KEY_ENTITY_IDENTIFIER, mEntityIdentifier); return bundle; }
/** * Serializes this {@link Action} object to a {@link org.json.JSONObject} representation. */ public JSONObject toJson() throws JSONException { JSONObject jsonObject = new JSONObject(); jsonObject.put(KEY_TITLE, mTitle); jsonObject.put(KEY_VIEW_INTENT, (mViewIntent != null) ? mViewIntent.toUri(Intent.URI_INTENT_SCHEME) : null); jsonObject.put(KEY_ENTITY_IDENTIFIER, mEntityIdentifier); return jsonObject; }
Intent intent = new Intent(context, WidgetService.class); intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, currentWidgetId); intent.putExtra("random", randomNumber); randomNumber++; intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
toastIntent.setAction(ChecksWidgetProvider.TOAST_ACTION); toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); toastIntent.setData(Uri.parse(toastIntent.toUri(Intent.URI_INTENT_SCHEME))); final PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent, PendingIntent.FLAG_UPDATE_CURRENT); rv.setPendingIntentTemplate(android.R.id.list, toastPendingIntent);
return intent.toUri(Intent.URI_INTENT_SCHEME);
String intentUri = target.toUri(0); String packageName = null; String resourceName = null;
public class CalendarChangedReceiver extends BroadcastReceiver { private static final String TAG = "CalendarChangedReceiver"; @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "calendar changed! "+intent.toUri(Intent.URI_INTENT_SCHEME)); } }