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 ... "));
}
}
--
In questa pagina del sito puoi guardare il video online How to share bitmap image over Telegram, WhatsApp, google photos, etc. from your Android App? della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Programmer World 13 gennaio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 1,443 volte e gli è piaciuto 13 spettatori. Buona visione!