android.content.Intent.toUri()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(498)

本文整理了Java中android.content.Intent.toUri()方法的一些代码示例,展示了Intent.toUri()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Intent.toUri()方法的具体详情如下:
包路径:android.content.Intent
类名称:Intent
方法名:toUri

Intent.toUri介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

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));

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: android-hacker/VirtualXposed

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);
    }
  }
}

代码示例来源:origin: commonsguy/cw-omnibus

@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());
  }
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

@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);
 }
}

代码示例来源:origin: android-hacker/VirtualXposed

shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
if (splash != null) {
  shortcutIntent.putExtra("_VA_|_splash_", splash.toUri(0));
shortcutIntent.putExtra("_VA_|_uri_", targetIntent.toUri(0));
shortcutIntent.putExtra("_VA_|_user_id_", VUserHandle.myUserId());

代码示例来源:origin: android-hacker/VirtualXposed

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);

代码示例来源:origin: hidroh/materialistic

@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));
}

代码示例来源:origin: stackoverflow.com

return intent.toUri(Intent.URI_INTENT_SCHEME);

代码示例来源:origin: k9mail/k-9

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);
}

代码示例来源:origin: commonsguy/cw-omnibus

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);
}

代码示例来源:origin: android-hacker/VirtualXposed

shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
persistableBundle.putString("_VA_|_uri_", intent.toUri(0));
persistableBundle.putInt("_VA_|_user_id_", 0);
swap[i] = shortcutIntent;

代码示例来源:origin: android-hacker/VirtualXposed

shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT);
if (splash != null) {
  shortcutIntent.putExtra("_VA_|_splash_", splash.toUri(0));
shortcutIntent.putExtra("_VA_|_uri_", targetIntent.toUri(0));
shortcutIntent.putExtra("_VA_|_user_id_", userId);

代码示例来源:origin: UweTrottmann/SeriesGuide

/**
 * 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;
}

代码示例来源:origin: UweTrottmann/SeriesGuide

/**
 * 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;
}

代码示例来源:origin: stackoverflow.com

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)));

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: weexteam/weex-hackernews

return intent.toUri(Intent.URI_INTENT_SCHEME);

代码示例来源:origin: Neamar/KISS

String intentUri = target.toUri(0);
String packageName = null;
String resourceName = null;

代码示例来源:origin: stackoverflow.com

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));
  }
}

相关文章

Intent类方法