How to share bitmap image over Telegram, WhatsApp, google photos, etc. from your Android App?

Publicado em: 13 Janeiro 2023
no canal de: Programmer World
1,443
13

This video shows the steps to share an image over other applications such as Telegram, WhatsApp, google photos, etc. directly from your Android App.

In this video it shares the image in bitmap form (as an image) and not as a file.

To share the complete files one can refer to the details shown in the below link:
https://programmerworld.co/android/ho...



I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: [email protected]


Complete source code and other details/ steps of this video are posted in the below link:
https://programmerworld.co/android/ho...



However, the main Java code is copied below also for reference:


package com.programmerworld.sharebitmapimage_telegramwhatsapp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.MediaStore;
import android.view.View;
import android.widget.ImageView;

import java.io.File;

public class MainActivity extends AppCompatActivity {

private ImageView imageView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ActivityCompat.requestPermissions(this,
new String[]{Manifest.permission.READ_MEDIA_IMAGES},
PackageManager.PERMISSION_GRANTED);

imageView = findViewById(R.id.imageView);
}

public void buttonShareBitmap(View view){
StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
StorageVolume storageVolume = storageManager.getStorageVolumes().get(0); // internal memory
File fileImage = new File(storageVolume.getDirectory().getPath() + "/Download/images.jpeg");
Bitmap bitmap = BitmapFactory.decodeFile(fileImage.getPath());
imageView.setImageBitmap(bitmap);
String stringPath = MediaStore.Images.Media.insertImage(this.getContentResolver(),
bitmap,"Shared Image", null);

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(stringPath));

startActivity(Intent.createChooser(intent, "Share the Image ... "));
}
}



--


Nesta página do site você pode assistir ao vídeo on-line How to share bitmap image over Telegram, WhatsApp, google photos, etc. from your Android App? duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Programmer World 13 Janeiro 2023, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 1,443 vezes e gostou 13 espectadores. Boa visualização!