弹出分享对话框

来源:互联网 发布:linux rand 编辑:程序博客网 时间:2024/05/18 14:13
Intent sendIntent = new Intent(Intent.ACTION_SEND);
    
    sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
    sendIntent.setType("text/plain");
    String title = "Share this with";
    // Create and start the chooser
    Intent chooser = Intent.createChooser(sendIntent, title);
    startActivity(chooser);

弹出分享对话框

//发送一张图片

Intent shareIntent = new Intent();
    
    Filefile = new File("mnt/sdcard/share.png");
    
    System.out.println(Uri.fromFile(file));
    
    shareIntent.setAction(Intent.ACTION_SEND);
    
    shareIntent.putExtra(Intent.EXTRA_STREAM,file);
    
    shareIntent.setType("image/jpeg");


    Stringtitle = "Share this with";


    //Create and start the chooser
    Intentchooser = Intent.createChooser(shareIntent, title);


    startActivity(chooser);

0 0
原创粉丝点击