android实现分享,打开网页链接等简单功能
2017-11-12 本文已影响9人
Gear_033e
- 分享
public class ShareUtils {
public static void share(Context context, String shareText) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, shareText);
context.startActivity(Intent.createChooser(intent, "分享分享"));
}
}
shareText里填充文字, url等内容;
2.在浏览器中打开网络链接
public static void openUrl(Context context, String url) {
Uri uri = Uri.parse(url);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
context.startActivity(intent);
}