简体   繁体   中英

How to share full screen image android?

I am displaying image in the view pager by fetching from the server.I am not displaying the full screen image.I have added the feature to share the image via email or many other options.

code to share image

imageView = (TouchImageView) viewpager.findViewWithTag(viewpager
            .getCurrentItem());
    imageView.setDrawingCacheEnabled(true);
    Bitmap bitmap = imageView.getDrawingCache();
    String path = Images.Media.insertImage(getContentResolver(), bitmap,
            "description", null);
    uri = Uri.parse(path);
    Intent send_report = new Intent(Intent.ACTION_SEND);
    send_report.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
    send_report.putExtra(Intent.EXTRA_SUBJECT, "Give Me That Picture");
    send_report.putExtra(Intent.EXTRA_STREAM, uri);
    send_report.putExtra(Intent.EXTRA_TEXT, "cool picture");
    send_report.setType("text/plain");
    send_report.setType("image/png");
    startActivityForResult(
    Intent.createChooser(send_report, "Choose an Email client"), 77);

But the image which is shared is not a full screen image.But i want to share the actual size image.Please help me out on this.

UPDATE view pager adapter

public class ImagePagerAdapter extends PagerAdapter {
        LayoutInflater inflater;
        PhotoViewAttacher attacher;
        PhotoViewAttacher pic;

        private DisplayImageOptions options;
        private List<Wallpaper> IMAGES_LIST = AppController.getInstance()
                .getPrefManger().getAllImages();




        public ImagePagerAdapter(Context context) {
            inflater = LayoutInflater.from(context);
            options = new DisplayImageOptions.Builder()
                    .showImageForEmptyUri(R.drawable.ic_empty)
                    .showImageOnFail(R.drawable.ic_error)
                    .resetViewBeforeLoading(true).cacheOnDisk(true)
                    .imageScaleType(ImageScaleType.EXACTLY)
                    .bitmapConfig(Bitmap.Config.RGB_565)
                    .considerExifParams(true)
                    .displayer(new FadeInBitmapDisplayer(300)).build();
        }

        @Override
        public Object instantiateItem(ViewGroup container, final int position) {
            final View imageLayout = inflater.inflate(
                    R.layout.item_pager_image, container, false);
            assert imageLayout != null;
            pos = position;
            imageView = (TouchImageView) imageLayout.findViewById(R.id.image);
            // pic=new PhotoViewAttacher(imageView);
            imageView.setTag(position);

            imageView.setOnDoubleTapListener(new OnDoubleTapListener() {

                @Override
                public boolean onSingleTapConfirmed(MotionEvent e) {
                    // TODO Auto-generated method stub
                    Log.i("hello", "sinfle");
                    mHandler.removeCallbacks(r);
                    share.setVisibility(View.VISIBLE);
                    done.setVisibility(View.VISIBLE);
                    gimmy.setVisibility(View.VISIBLE);
                    comment.setVisibility(View.VISIBLE);
                    mHandler.postDelayed(r, 5 * 1000);
                    return false;
                }

                @Override
                public boolean onDoubleTapEvent(MotionEvent e) {
                    // TODO Auto-generated method stub
                    Log.i("hello", "donl");

                    return false;
                }

                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    // TODO Auto-generated method stub
                    return false;
                }
            });

            share.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {
                    // TODO Auto-generated method stub
                    showShareDialog();
                }

            });

            final ProgressBar spinner = (ProgressBar) imageLayout
                    .findViewById(R.id.loading);

            ImageLoader.getInstance().displayImage(
                    IMAGES_LIST.get(position).getUrl(), imageView, options,
                    new SimpleImageLoadingListener() {
                        @Override
                        public void onLoadingStarted(String imageUri, View view) {
                            spinner.setVisibility(View.VISIBLE);
                            view.setVisibility(View.GONE);
                        }

                        @Override
                        public void onLoadingFailed(String imageUri, View view,
                                FailReason failReason) {
                            String message = null;
                            switch (failReason.getType()) {
                            case IO_ERROR:
                                message = "Input/Output error";
                                break;
                            case DECODING_ERROR:
                                message = "Image can't be decoded";
                                break;
                            case NETWORK_DENIED:
                                message = "Downloads are denied";
                                break;
                            case OUT_OF_MEMORY:
                                message = "Out Of Memory error";
                                break;
                            case UNKNOWN:
                                message = "Unknown error";
                                break;
                            }
                            Toast.makeText(view.getContext(), message,
                                    Toast.LENGTH_SHORT).show();

                            spinner.setVisibility(View.GONE);
                        }

                        @Override
                        public void onLoadingComplete(String imageUri,
                                View view, Bitmap loadedImage) {
                            spinner.setVisibility(View.GONE);
                            view.setVisibility(View.VISIBLE);


                        }
                    });

            container.addView(imageLayout, 0);
            return imageLayout;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

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

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

        @Override
        public void restoreState(Parcelable state, ClassLoader loader) {
        }

        @Override
        public Parcelable saveState() {
            return null;
        }

    }

You've already set cacheOnDisk(true) , so now you want to take an image from it by:

File cachedImage = imageLoader.getDiscCache().get(imageUrl);
if (cachedImage.exists()) {
    /// get your image from file
}

如果您在视图寻呼机中获取当前图像的缓存,那么您将获得带有边距的视图寻呼机上显示的视图。您需要从服务器下载图像。在视图寻呼机中获取当前显示图像的URL并下载来自服务器的图像。这将解决您的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM