分享,发送;AlertDialog自定义布局文件

本文介绍了如何在Android应用中实现内容分享功能,包括通过短信、邮件发送内容,以及使用Intent来提供多种分享选项。文中还展示了如何创建对话框并自定义其布局。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发送为短信息内容

Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("sms", "", null));
i.putExtra("sms_body", cur.getString(3));
EditNote.this.startActivity(i);

发送电子邮件

Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "", null));
EditNote.this.startActivity(i);

应用程序自动检测:

Intent intent=new Intent(Intent.ACTION_SEND);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT,cur.getString(3));
EditNote.this.startActivity(Intent.createChooser(intent, getString(R.string.dialog_send)));

对话框添加布局:AlertDialog

LayoutInflater inflater = LayoutInflater.from(this);
final View choiceView = inflater.inflate(R.layout.choice_activity, null);
AlertDialog mAlertDialog = new AlertDialog.Builder(this)
.setTitle(R.string.search_widget)
.setView(choiceView)
.create();
mAlertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
public void onDismiss(DialogInterface dialog) {
SearchWidgetConfigActivity.this.finish();
}
});

mAlertDialog.show();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值