2013-07-25 1 views
1

이봐, 난 인스 타 그램에 이미지 뷰에 내 이미지를 공유하고 싶은 내가안드로이드 - 이미지 뷰

내가 응용 프로그램을 실행 내가 다른 활동에서 내 사진을 찍어 이미지를 공유하려는 전에 내가 ACTION_SEND 를 사용하고 난의 조치 제공자에게 공유 이미지

를 "파일을 다운로드 할 수 없습니다"라는 메시지를 받고이 내 코드를 확인 .... 내 코드입니다 OnClickListener를에 오류

import android.app.Activity; 
import android.content.Intent; 
import android.graphics.Bitmap; 
import android.graphics.BitmapFactory; 
import android.net.Uri; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.ImageView; 
import android.widget.TextView; 
import android.widget.Toast; 

import java.io.File; 

public class editPhoto extends Activity { 

    String picturePath; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     overridePendingTransition(R.anim.push_left_in, R.anim.hold); 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.page); 

     picturePath = getIntent().getStringExtra("selectedPhoto"); 

     Bitmap bitmap = BitmapFactory.decodeFile(picturePath); 
     ImageView imageView = (ImageView) findViewById(R.id.iv_pic); 
     imageView.setImageBitmap(bitmap); 

     TextView tv = (TextView) findViewById(R.id.imagepath); 
     tv.setText(picturePath); 

     Button share = (Button) findViewById(R.id.btnShare); 

     share.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       Intent intent = new Intent(Intent.ACTION_SEND); 
       intent.setType("image/*"); 
       intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(picturePath)); 
       startActivity(Intent.createChooser(intent, "Share")); 

      } 
     }); 
    } 
} 

답변

0

넣어

경우
   imageView.setDrawingCacheEnabled(true); 
       Bitmap bitmap = imageView.getDrawingCache(); 
       File root = Environment.getExternalStorageDirectory(); 
       File cachePath = new File(root.getAbsolutePath() + "/DCIM/Camera/image.jpg"); 
       try { 
        cachePath.createNewFile(); 
        FileOutputStream ostream = new FileOutputStream(cachePath); 
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, ostream); 
        ostream.close(); 
       } catch (Exception e) { 
        e.printStackTrace(); 
       } 


       Intent share = new Intent(Intent.ACTION_SEND); 
       share.setType("image/*"); 
       share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(cachePath)); 
       startActivity(Intent.createChooser(share,"Share via")); 
+0

들여 쓰기를 수정하십시오. – ANjaNA