Android 앱에서 MMS 또는 소셜 미디어 앱으로 드로어 블 이미지를 보내는 방법은 무엇입니까?

자 우라

첨부 파일로 메시징을 위해 앱에서 내 이미지를 공유 할 수 없습니다. 드로어 블 이미지의 int 배열 목록이 있습니다.

final int [] imagelistId={
        R.drawable.birthday1,
        R.drawable.birthday2,
        R.drawable.birthday3,
        R.drawable.birthday4,
        R.drawable.birthday5,
        R.drawable.birthday6,
    };

그 후 이미지를 첨부 파일로 공유하기위한이 코드가 있습니다.

smsBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent smsIntent = new Intent(Intent.ACTION_SENDTO);
                // add the message at the sms_body extra field
                smsIntent.setData(Uri.parse("mmsto:"));
                smsIntent.setType("image/*");
                smsIntent.putExtra("sms_body", "Image");
                smsIntent.putExtra("subject", "Image Message");
                smsIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("android.resource://com.example.finalgreetings/" + imagelistId[pos]) );
                try{
                    mcontext.startActivity(smsIntent);
                } catch (Exception ex) {
                    Toast.makeText(mcontext, "Your sms has failed...",
                            Toast.LENGTH_LONG).show();
                    ex.printStackTrace();
                }
            }
        });

많은 스택 오버플로 질문을 보았지만 내 문제에 대한 답변이 없습니다. 또한 드로어 블을 비트 맵으로 변환하고 내부 또는 외부 저장소에 저장 한 다음 공유하는 방법을 읽었습니다. 친절하고 가장 쉬운 해결책을 제안하십시오. 미리 고맙습니다.

Nils

이 시도..!!!

smsBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {               
                Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.yourimage);//put here your image id
                String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/LatestShare.png";
                OutputStream out = null;
                File file = new File(path);
                try {
                    out = new FileOutputStream(file);
                    bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
                    out.flush();
                    out.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                path = file.getPath();
                Uri bmpUri = Uri.parse("file://" + path);
                Intent shareIntent = new Intent();
                shareIntent = new Intent(Intent.ACTION_SEND);
                shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
                shareIntent.setType("image/png");
                startActivity(Intent.createChooser(shareIntent, "Share with"));

        }
    });

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관