第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何使用“共享圖像使用”共享意圖共享圖像在Android?

如何使用“共享圖像使用”共享意圖共享圖像在Android?

胡子哥哥 2019-08-02 07:02:32
如何使用“共享圖像使用”共享意圖共享圖像在Android?我有圖像廚房的應(yīng)用程序,我把所有的圖像放在繪圖-hdpi文件夾。在我的活動(dòng)中,我把圖像叫做:private Integer[] imageIDs = {         R.drawable.wall1, R.drawable.wall2,         R.drawable.wall3, R.drawable.wall4,         R.drawable.wall5, R.drawable.wall6,         R.drawable.wall7, R.drawable.wall8,         R.drawable.wall9, R.drawable.wall10};因此,現(xiàn)在我想知道如何使用共享意圖共享這些圖像,我提供了這樣的共享代碼:     Button shareButton = (Button) findViewById(R.id.share_button);      shareButton.setOnClickListener(new View.OnClickListener() {      public void onClick(View v) {         Intent sharingIntent = new Intent(Intent.ACTION_SEND);         Uri screenshotUri = Uri.parse(Images.Media.EXTERNAL_CONTENT_URI + "/" + imageIDs);         sharingIntent.setType("image/jpeg");         sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);         startActivity(Intent.createChooser(sharingIntent, "Share image using"));            }     });我也有分享按鈕,當(dāng)我點(diǎn)擊共享按鈕共享框打開(kāi),但當(dāng)我剪裁任何服務(wù),大部分是它的崩潰或一些服務(wù)說(shuō):無(wú)法打開(kāi)圖像,所以我如何能夠修復(fù)這個(gè),或者有任何格式代碼來(lái)共享圖像?編輯:我試過(guò)使用下面的代碼。但這不起作用。Button shareButton = (Button) findViewById(R.id.share_button);      shareButton.setOnClickListener(new View.OnClickListener() {      public void onClick(View v) {         Intent sharingIntent = new Intent(Intent.ACTION_SEND);         Uri screenshotUri = Uri.parse("android.resource://com.android.test/*");         try {             InputStream stream = getContentResolver().openInputStream(screenshotUri);         } catch (FileNotFoundException e) {             // TODO Auto-generated catch block             e.printStackTrace();         }         sharingIntent.setType("image/jpeg");         sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);         startActivity(Intent.createChooser(sharingIntent, "Share image using"));            }     });如果不介意的話,請(qǐng)更正我上面的代碼,或者給我一個(gè)適當(dāng)?shù)氖纠齪lz,我如何共享可繪制-hdpi文件夾中的圖像?
查看完整描述

3 回答

?
RISEBY

TA貢獻(xiàn)1856條經(jīng)驗(yàn) 獲得超5個(gè)贊

Bitmap icon = mBitmap;Intent share = new Intent(Intent.ACTION_SEND);share.setType("image/jpeg");ByteArrayOutputStream bytes = new ByteArrayOutputStream();icon.compress(Bitmap.CompressFormat.JPEG, 100, bytes);File f = new File(Environment.getExternalStorageDirectory() + File.separator + "temporary_file.jpg");try {
    f.createNewFile();
    FileOutputStream fo = new FileOutputStream(f);
    fo.write(bytes.toByteArray());} catch (IOException e) {                       
        e.printStackTrace();}share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/temporary_file.jpg"));startActivity(Intent.createChooser(share, "Share Image"));




查看完整回答
反對(duì) 回復(fù) 2019-08-03
  • 3 回答
  • 0 關(guān)注
  • 430 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)