分享

Intent的两个基本用法

 昵称65753755 2019-08-12

一、调用系统默认浏览器打开一个指定网址:

public void onGoogleButtonClick(View view) {

     Uri uri = Uri.parse("http://www.");
  Intent intent=new Intent(Intent.ACTION_VIEW,uri);
     startActivity(intent);
    }
    

 

二、调出分享界面,分享一段无格式文本

public void onShareButtonClick(View view)
    {
     Intent intent=new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "This is my text to send");
startActivity(intent);
    }

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多