Android - 从Imageview向动作提供者分享图像

时间:2013-07-25 09:19:32

标签: android shareactionprovider

嘿我想在imageview中将我的图片分享到Instagram,并使用ACTION_SEND 在我想分享图片之前,我从其他活动中获取我的照片

我运行app并收到消息“无法下载文件”

这是我的代码....检查我的代码是否有任何错误

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"));

            }
        });
    }
}

1 个答案:

答案 0 :(得分:0)

放入onClickListener

soundarya@soundarya-VirtualBox:~/Downloads/elasticsearch-2.4.0/bin$ curl -XPUT 'http://localhost:9200/aida' -d '{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "char_filter": [
            "my_char_filter"
          ],
          "filter": [
            "uppercase"
            ]
        }
      },
      "char_filter": {
        "my_char_filter": {
          "type": "pattern_replace",
          "pattern": "(\\d+)-(?=\\d)",
          "replacement": "$1 "
        }
      }
    }
  }
}
'
{"acknowledged":true}


soundarya@soundarya-VirtualBox:~/Downloads/elasticsearch-2.4.0/bin$ curl -XPOST 'http://localhost:9200/aida/_analyze?pretty' -d '{
"analyzer":"my_analyzer",
"text":"My name is Soun*arya?jwnne&yuuk"
}'