I want to share text message trough twitter, facebook or in other ways that available on device. I wrote next code:
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_TEXT, "Here's some text for Twitter.");
startActivity(Intent.createChooser(share, "Share this via"));
But if no apps that can hadle this action, the "no such apps" dialog appears on screen. I want to detect these apps and disable this function if there is no handlers found. How I can do it?
ActivityCompat. startActivityForResult(this, new Intent(this, MyActivity. class), 0, null);
This Intent object can be retrieved via the getIntent() method. The component which receives the intent can use the getIntent(). getExtras() method call to get the extra data.
Android Intent is the message that is passed between components such as activities, content providers, broadcast receivers, services etc. It is generally used with startActivity() method to invoke activity, broadcast receivers etc. The dictionary meaning of intent is intention or purpose.
Intent intent = new Intent...
PackageManager manager = mContext.getPackageManager();
List<ResolveInfo> list = manager.queryIntentActivities(intent, 0);
if (list != null && list.size() > 0) {
//You have at least one activity to handle the intent
} else {
//No activity to handle the intent.
}
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