When I share Text to Whatsapp, How can I know if sharing is successful or canceled?
likes OnActivityForResult
. I want handy share`s status.
I have the solution for you, With the help of onActivityResult you can get a callback after sharing anything on WhatsApp. Please use following steps 1. Start your intent to receive result from another app
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivityForResult(sendIntent,1); //1 is request code
Step 2.Override onActivityResult in your activity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Toast.makeText(MainActivity.this.getApplicationContext(),"onActivityResult..:",Toast.LENGTH_SHORT).show();
if(resultCode==RESULT_OK) {
if (requestCode == 1) {
Toast.makeText(MainActivity.this.getApplicationContext(), "Got Callback yeppeee...:", Toast.LENGTH_SHORT).show();
}
}
}