0

Hi guys I am totally new in android app development and need some helped. Actually I am working on project i.e. WhatsApp Status Saver.

I did some basic coding. But Now I want to share video from VideoView.

I done the code for sending Images.

I used the following code.

public class Picture extends AppCompatActivity {
    ImageView mparticularimage, 
    share;
    BitmapDrawable drawable;
    Bitmap bitmap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_picture);
        getSupportActionBar().setTitle("Picture");
        mparticularimage=findViewById(R.id.particularImage);
        share=findViewById(R.id.share);
        
   

        share.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //shareoption coding
                shareImage();
            }
        });

       
 private void shareImage() {
        StrictMode.VmPolicy.Builder builder = new StrictMode.VmPolicy.Builder();
        StrictMode.setVmPolicy(builder.build());
        drawable = (BitmapDrawable) mparticularimage.getDrawable();
        bitmap = drawable.getBitmap();
        File file = new File(getExternalCacheDir()+"/"+"Status downloaded by - Status saver"+".png");
        Intent intent;
        try {
            FileOutputStream outputStream = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.JPEG,100, outputStream);
            outputStream.flush();
            outputStream.close();
            intent = new Intent(Intent.ACTION_SEND);
            intent.setType("image/+");
            intent.putExtra(intent.EXTRA_STREAM, Uri.fromFile(file));
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }catch (Exception e){
            throw new RuntimeException(e);
        }
        startActivity(Intent.createChooser(intent,"Share this image via: "));
    }

}

The above code perfectly work for Images now how to do the same thing in terms of VideoView and .mp4 files.

0 Answers0