Sending text content putExtra(Intent. EXTRA_TEXT, "This is my text to send.") Intent sendIntent = new Intent();
An intent is to perform an action on the screen. It is mostly used to start activity, send broadcast receiver,start services and send message between two activities. There are two intents available in android as Implicit Intents and Explicit Intents. Here is a sample example to start new activity with old activity.
setPackage("org. telegram. messenger");
I am trying to create a class in java which manages different social sharing apps. The class is based on android intents.
but when I try to execute Telegram intent, it doesn't find the app.
Here I put the code I have written:
public void shareTelegram(String message) { Intent waIntent = new Intent(Intent.ACTION_SEND); waIntent.setType("text/plain"); waIntent.setPackage("com.telegram"); if (waIntent != null) { waIntent.putExtra(Intent.EXTRA_TEXT, message);// _androidActivity.startActivity(Intent.createChooser(waIntent, "Share with")); } else { Toast.makeText(_androidActivity.getApplicationContext(), "Telegram is not installed", Toast.LENGTH_SHORT).show(); } }
Where could I find the package name? Thanks in advance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With