2012-12-10 2 views
1

내가 SO뿐만 아니라 구글에 여전히 적합한 솔루션의 yet.My 코드를 얻을하지 여기에 많이 발견 Android.I에 MMS에 텍스트 내에서 이미지를 첨부 할 것은있는 그대로 :안드로이드에서 이미지 첨부 및 일부 텍스트로 MMS를 보내는 방법은 무엇입니까?

Intent sendIntent = new Intent(Intent.ACTION_SEND); 
      sendIntent.setType("image/png"); 
      sendIntent.putExtra("sms_body", 
        getResources().getText(R.string.Message)); 
      // sendIntent.setType("vnd.android-dir/mms-sms"); 

      Uri mms_uri = Uri.parse("android.resource://" 
        + getPackageName() + "/" + R.drawable.app_logo); 

      sendIntent.putExtra(Intent.EXTRA_STREAM, mms_uri.toString()); 

      startActivity(Intent.createChooser(sendIntent, "")); 

제발 도와주세요 내 이슈에 대한 나.

+0

현재 코드를 실행할 때 오류가 발생합니까? –

+0

아무런 오류가 발생하지 않지만 it.i 이미지를 첨부 할 수 없습니다. 내가 어디 잘못 됐는지 알지 못합니다. MMS 이미지 첨부와 관련하여 제안 할 수 있습니까? – Biginner

답변

0

행운이 있었나요? 나는 비슷한 접근법을 시도해 보았고 그 사실이 발견되었다.

Uri mms_uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.drawable.app_logo); 

은 보편적이지 않다. 애셋 폴더에서 이미지 파일의 복사본을 만들어 파일로 변환하여 관리했습니다. 다음과 같이 할 수 있습니다 :

File f = new File(getCacheDir()+"/app_logo.png"); 
if (!f.exists()) try { 
    InputStream is = getAssets().open("R.drawable.app_logo"); 
    int size = is.available(); 
    byte[] buffer = new byte[size]; 
    is.read(buffer); 
    is.close(); 

    FileOutputStream fos = new FileOutputStream(f); 
    fos.write(buffer); 
    fos.close(); 
} catch (Exception e) { throw new RuntimeException(e); } 

sharePicture = f.getPath(); 
관련 문제