Ritesh Mathur Ritesh Mathur - 6 months ago 21
Android Question

How to invoke email ,message box, whtasapp using intent filter

I am using intent filter i.e ACTION_SEND for invoking email,message box, whtasapp
and i want to fix some elements like if user click on message box at that time mobile number come automatically which i have set and when user select email then receiver mail id come automatically
I made a code for email but wouldn't getting number in message box
I am writing my code here

smsbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"xyz@gmail.com"});
intent.putExtra(Intent.EXTRA_PHONE_NUMBER,"9999999999");

//Intent receiver = new Intent(getApplicationContext(), ShareActivity.class);
//receiver.putExtra("test", "test");
// PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, receiver, PendingIntent.FLAG_UPDATE_CURRENT);
Intent chooser = Intent.createChooser(intent, "Share");
startActivity(chooser);
}
});

<activity
android:name=".ShareActivity">
<!-- This activity handles "SEND" actions with text data -->
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain" />
<data android:scheme="tel" />
</intent-filter>
<!-- This activity also handles "SEND" and "SEND_MULTIPLE" with media data -->

</activity>

Answer
     Intent sendIntent = new Intent(Intent.ACTION_VIEW);
     sendIntent.setType("vnd.android-dir/mms-sms");
     sendIntent.putExtra("address", mobile no here);
     context.startActivity(sendIntent);

Please try the above codes to pass mobile no.