乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Android 實(shí)現(xiàn)系統(tǒng)分享

       Coder編程 2022-01-13

       

       

      1、分享/發(fā)送文本內(nèi)容

      1  Intent shareIntent = new Intent();
      2         shareIntent.setAction(Intent.ACTION_SEND);
      3         shareIntent.setType("text/plain");
      4         //要分享的文本內(nèi)容,選擇某項(xiàng)后會直接把這段文本發(fā)送出去,相當(dāng)于調(diào)用選中的應(yīng)用的接口,并傳參
      5         shareIntent.putExtra(Intent.EXTRA_TEXT, "Here is the Shared text.");
      6         //需要使用Intent.createChooser,這里我們直接復(fù)用。第二個參數(shù)并不會顯示出來
      7         shareIntent = Intent.createChooser(shareIntent, "Here is the title of Select box");
      8         startActivity(shareIntent);

       

       

      通用步驟:

      首先將Intent的cation設(shè)置為Intent.ACTION_SEND,

      其次根據(jù)分享的內(nèi)容設(shè)置不同的Type,

      然后根據(jù)不同的社交平臺設(shè)置相關(guān)Extras,

      最后創(chuàng)建并啟動選擇器

       

       

      2、分享/發(fā)送單張圖片

      1   //指定要分享的圖片路徑
      2          Uri imgUri = Uri.parse("mnt/sdcard/1.jpg" );
      3         意圖 shareIntent = new Intent();
      4          shareIntent.setAction(Intent.ACTION_SEND);
      5          shareIntent.putExtra(Intent.EXTRA_STREAM, imgUri);
      6          shareIntent.setType("image/*" );
      7          shareIntent = Intent.createChooser(shareIntent, "這里是選擇框的標(biāo)題" );
      8          startActivity(shareIntent);

      注意根目錄為     mnt/sdcard/   

       

       

      3、分享/發(fā)送多張圖片

       1  Uri imgUri1 = Uri.parse("mnt/sdcard/1.jpg");
       2         Uri imgUri2 = Uri.parse("mnt/sdcard/2.jpg");
       3         ArrayList<Uri> imgUris = new ArrayList<Uri>();   //使用集合保存
       4         imgUris.add(imgUri1); 
       5         imgUris.add(imgUri2); 
       6 
       7         Intent shareIntent = new Intent();
       8         shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE);    //注意是Intent_ACTION_MULTIPLE
       9         shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, imgUris);   //注意是方法是putParcelableArrayListExtra()
      10         shareIntent.setType("image/*" );
      11          shareIntent = Intent.createChooser(shareIntent, "這里是選擇框的標(biāo)題" );
      12          startActivity(shareIntent);

       

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多