Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sending image through intent

 
arjun narahari
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i wrote a program in which my images are read from sdcard and shown in as a gridview and when clicked on any image on the gridview , bigger image opens in another activity , i have also added a share button to share my image to different applications example whatsapp , so when i click on share , a chooser popsup and i also reach safely inside whatsapp where i select a user but when i select a user my image is not shown , below is the picture of the screen after i select a user

My code for the above

public class FullScreenImageAdapter extends PagerAdapter {

private Activity _activity;
private ArrayList<String> _imagePaths;
private LayoutInflater inflater;
Intent intent, chooser;

// constructor
public FullScreenImageAdapter(Activity activity,
ArrayList<String> imagePaths) {
this._activity = activity;
this._imagePaths = imagePaths;
}

@Override
public int getCount() {
return this._imagePaths.size();
}

@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((RelativeLayout) object);
}

@Override
public Object instantiateItem(final ViewGroup container, int position) {
TouchImageView imgDisplay;
final Button btnClose, btnShare;

inflater = (LayoutInflater) _activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View viewLayout = inflater.inflate(R.layout.layout_fullscreen_imag,
container, false);

imgDisplay = (TouchImageView) viewLayout.findViewById(R.id.imgDisplay);
btnClose = (Button) viewLayout.findViewById(R.id.btnClose);
btnShare = (Button) viewLayout.findViewById(R.id.btnShare);

BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bitmap = BitmapFactory.decodeFile(_imagePaths.get(position),
options);
imgDisplay.setImageBitmap(bitmap);


btnShare.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
intent = new Intent(Intent.ACTION_SEND);
Uri imageuri = Uri.parse("file://sdcard//Pictures//raw "
+ _imagePaths);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, imageuri);
chooser = Intent.createChooser(intent, "Share image via....");
container.getContext().startActivity(chooser);

}
});

((ViewPager) container).addView(viewLayout);

return viewLayout;
}
i need to know where i am going wrong and please give suggestions thanking you
2014-11-18 15.09.30.png
[Thumbnail for 2014-11-18 15.09.30.png]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds as if there are two problems - an image not being show in a View, and sharing the image not working. If this was my problem, I'd separate the issues and debug them one by one, starting with the problem of the image not being shown in the view.

You could starting by making sure that the "bitmap" object is indeed a valid image - maybe save it to a file and make sure you can view it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic