1

我有以下代码:

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Share with...");
    final ShareAdapter adapter = new ShareAdapter(this, R.layout.share_adapter, activities.toArray());
    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            ResolveInfo info = (ResolveInfo) adapter.getItem(which);


         }
     }

我要做的就是在 onClick 方法中添加一个 if 语句,我将在其中检查意图是否属于以下类型:message/rfc822。有没有办法做到这一点?我想这样做的原因是因为我想检测正在发送电子邮件的应用程序。然后通过以下方式发送电子邮件:

    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("text/html");
    intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(....
4

1 回答 1

1

Intents getType() 方法怎么样?请参阅:http: //developer.android.com/reference/android/content/Intent

于 2013-03-12T15:24:46.790 回答