• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending image through intent

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic