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

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

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

Intent.createChooser介绍

暂无

代码示例

代码示例来源:origin: HotBitmapGG/bilibili-android-client

/**
   * 分享链接
   */
  public static void shareLink(String url, String title, Context context) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
    intent.putExtra(Intent.EXTRA_TEXT, "非官方开源哔哩哔哩动画安卓客户端,GitHub地址:" + url);
    context.startActivity(Intent.createChooser(intent, title));
  }
}

代码示例来源:origin: square/leakcanary

private void startShareIntentChooser(Uri heapDumpUri) {
 Intent intent = new Intent(Intent.ACTION_SEND);
 intent.setType("application/octet-stream");
 intent.putExtra(Intent.EXTRA_STREAM, heapDumpUri);
 startActivity(Intent.createChooser(intent, getString(R.string.leak_canary_share_with)));
}

代码示例来源:origin: naman14/Timber

public static void shareTrack(final Context context, long id) {
  try {
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("audio/*");
    share.putExtra(Intent.EXTRA_STREAM, getSongUri(context, id));
    context.startActivity(Intent.createChooser(share, "Share"));
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: gzu-liyujiang/AndroidPicker

public void onContact(View view) {
  Intent intent = new Intent(Intent.ACTION_SENDTO);
  intent.setData(Uri.parse("mailto:liyujiang_tk@yeah.net"));
  intent.putExtra(Intent.EXTRA_CC, new String[]
      {"1032694760@qq.com"});
  intent.putExtra(Intent.EXTRA_EMAIL, "");
  intent.putExtra(Intent.EXTRA_TEXT, "欢迎提供意您的见或建议");
  startActivity(Intent.createChooser(intent, "选择邮件客户端"));
}

代码示例来源:origin: facebook/facebook-android-sdk

@Override
  public void onClick(View v) {
    Intent intent = new Intent();
    intent.setType(TYPE_IMAGE);
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, SELECT_PICTURE), PICK_IMAGE);
  }
});

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

@Override
@SuppressLint("InlinedApi")
public void showPickAttachmentDialog(int requestCode) {
  requestCode |= REQUEST_MASK_ATTACHMENT_PRESENTER;
  Intent i = new Intent(Intent.ACTION_GET_CONTENT);
  i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
  i.addCategory(Intent.CATEGORY_OPENABLE);
  i.setType("*/*");
  isInSubActivity = true;
  startActivityForResult(Intent.createChooser(i, null), requestCode);
}

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

private void onImport() {
  Intent i = new Intent(Intent.ACTION_GET_CONTENT);
  i.addCategory(Intent.CATEGORY_OPENABLE);
  i.setType("*/*");
  startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_SETTINGS_FILE);
}

代码示例来源:origin: aa112901/remusic

@Override
  public void onClick(View v) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("http://music.baidu.com/songlist/" + playlsitId));
    shareIntent.setType("html/*");
    startActivity(Intent.createChooser(shareIntent, getResources().getString(R.string.shared_to)));
  }
});

代码示例来源:origin: markzhai/AndroidPerformanceMonitor

private void shareHeapDump(BlockInfoEx blockInfo) {
  File heapDumpFile = blockInfo.logFile;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
    heapDumpFile.setReadable(true, false);
  }
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.setType("application/octet-stream");
  intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(heapDumpFile));
  startActivity(Intent.createChooser(intent, getString(R.string.block_canary_share_with)));
}

代码示例来源:origin: TeamNewPipe/NewPipe

private void shareUrl(String subject, String url) {
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.setType("text/plain");
  intent.putExtra(Intent.EXTRA_SUBJECT, subject);
  intent.putExtra(Intent.EXTRA_TEXT, url);
  startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
}

代码示例来源:origin: TeamNewPipe/NewPipe

protected void shareUrl(String subject, String url) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_TEXT, url);
    startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
  }
}

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

void sendIt(String theMessage) {
  Intent i=new Intent(Intent.ACTION_SEND);

  i.setType("text/plain");
  i.putExtra(Intent.EXTRA_SUBJECT, R.string.share_subject);
  i.putExtra(Intent.EXTRA_TEXT, theMessage);

  startActivity(Intent.createChooser(i,
                    getString(R.string.share_title)));
 }
}

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

void sendIt(String theMessage) {
  Intent i=new Intent(Intent.ACTION_SEND);

  i.setType("text/plain");
  i.putExtra(Intent.EXTRA_SUBJECT, R.string.share_subject);
  i.putExtra(Intent.EXTRA_TEXT, theMessage);

  startActivity(Intent.createChooser(i,
                    getString(R.string.share_title)));
 }
}

代码示例来源:origin: square/leakcanary

void shareLeak() {
 AnalyzedHeap visibleLeak = getVisibleLeak();
 String leakInfo = leakInfo(this, visibleLeak.heapDump, visibleLeak.result, true);
 Intent intent = new Intent(Intent.ACTION_SEND);
 intent.setType("text/plain");
 intent.putExtra(Intent.EXTRA_TEXT, leakInfo);
 startActivity(Intent.createChooser(intent, getString(R.string.leak_canary_share_with)));
}

代码示例来源:origin: PhilJay/MPAndroidChart

@Override
  public boolean onOptionsItemSelected(MenuItem item) {

    Intent i;

    switch (item.getItemId()) {
      case R.id.viewGithub:
        i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse("https://github.com/PhilJay/MPAndroidChart"));
        startActivity(i);
        break;
      case R.id.report:
        i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
            "mailto", "philjay.librarysup@gmail.com", null));
        i.putExtra(Intent.EXTRA_SUBJECT, "MPAndroidChart Issue");
        i.putExtra(Intent.EXTRA_TEXT, "Your error report here...");
        startActivity(Intent.createChooser(i, "Report Problem"));
        break;
      case R.id.website:
        i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse("http://at.linkedin.com/in/philippjahoda"));
        startActivity(i);
        break;
    }

    return true;
  }
}

代码示例来源:origin: TeamNewPipe/NewPipe

protected void openUrlInBrowser(String url) {
  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
  startActivity(Intent.createChooser(intent, activity.getString(R.string.share_dialog_title)));
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

@OnClick(R.id.btn_share)
  void share() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
    intent.putExtra(Intent.EXTRA_TEXT, "来自「哔哩哔哩」的分享:" + mVideoDetailsInfo.getDesc());
    startActivity(Intent.createChooser(intent, mVideoDetailsInfo.getTitle()));
  }
}

代码示例来源:origin: markzhai/AndroidPerformanceMonitor

private void shareBlock(BlockInfoEx blockInfo) {
  String leakInfo = blockInfo.toString();
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.setType("text/plain");
  intent.putExtra(Intent.EXTRA_TEXT, leakInfo);
  startActivity(Intent.createChooser(intent, getString(R.string.block_canary_share_with)));
}

代码示例来源:origin: facebook/facebook-android-sdk

private void startGalleryActivity() {
  tempUri = null;
  Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
  intent.setType("image/*");
  String selectPicture = getResources().getString(R.string.select_picture);
  startActivityForResult(Intent.createChooser(intent, selectPicture), getRequestCode());
}

代码示例来源:origin: robolectric/robolectric

@Test
public void createChooser_shouldWrapIntent() throws Exception {
 Intent originalIntent = new Intent(Intent.ACTION_BATTERY_CHANGED, Uri.parse("foo://blah"));
 Intent chooserIntent = Intent.createChooser(originalIntent, "The title");
 assertThat(chooserIntent.getAction()).isEqualTo(Intent.ACTION_CHOOSER);
 assertThat(chooserIntent.getStringExtra(Intent.EXTRA_TITLE)).isEqualTo("The title");
 assertThat((Intent) chooserIntent.getParcelableExtra(Intent.EXTRA_INTENT))
   .isSameAs(originalIntent);
}

相关文章

Intent类方法