Android : How do I integrate whatsapp calling - android

Is there any way to direct call to a number by whatsapp from another application?
I have tried to redirect for messaging by using below code and is working fine.
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(Intent.createChooser(i, ""));`
Is there any similar way for calling ?

I am not sure as I have not test this but hope this will work,
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + number));
callIntent.setPackage("com.whatsapp");
startActivity(callIntent);
And don't forget below permission in menifest file
<uses-permission android:name="android.permission.CALL_PHONE" />

Related

How to call # from program in android

I want to do this for my school project I want call from my app to show imei number so I want # also to be copied to phone call.But when I am executing the below code only the * is copied to phone call area
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + "*#06#"));
startActivity(intent);
in order to call USDD codes you have to use something like this :
String code = "*" + Uri.encode("#") + "06" + Uri.encode("#");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + code)));
and don't forget to use the call permission in your manifest :
<uses-permission android:name="android.permission.CALL_PHONE"/>

Text not passing to Whatsapp application using Intent

I am trying to launch whatsapp app from my app and passing some text to a particular number. Whatsapp App is launching and but text is not able to pass.
String smsNumber = "98*******3";
Uri uri = Uri.parse("smsto:" + smsNumber);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.putExtra(Intent.EXTRA_TEXT, textWithClickableLink);
i.setPackage("com.whatsapp");
mContext.startActivity(i);
Is there anything missing in my code?
Please help me on this.
Thanks in advance!
Try this one:
Uri uri = Uri.parse("smsto:" + mobileno);
Intent whatsappIntent = new Intent(Intent.ACTION_SENDTO, uri);
whatsappIntent.setPackage("com.whatsapp");
String str = "https://play.google.com/store/apps/details?id=com.example.activity&hl=en";
whatsappIntent.putExtra("sms_body", str);
try {
activity.startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
// Whatsapp have not been installed
}
you can try this method, it should work. I have tested
private void shareWhatsApp() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "text to share");
//if you have any images to share sue this, uri is the uri of image
//shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
//shareIntent.setType("image/*"); for image sharing
shareIntent.setType("text/plain");
shareIntent.setPackage("com.whatsapp");
startActivity(shareIntent);
}
This will launch WhatsApp application and you have to manually select the contacts and send. since they dont provide any SDK we cant send automatically.
I tried this code. It makes my app to open list of all app by which I can send messages. After selecting any app now I am able to send the message that I am attaching with intent.
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "From Stockal App");
intent.putExtra(Intent.EXTRA_TEXT, text);
mContext.startActivity(intent);
Thank you all for your response.

how to make a call from my application?

Need to make calls from my application, without invoking the default dialer Activity, i.e. my application's activity should complete the dial-out, conversation and hang-up operations.
Note that the usual way of invoking the default dialer Activity done as follows, is not what I need:
String nber = phone.getText().toString();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:" + nber));
startActivity(callIntent);
Try this
String nber = "tel:" + phone.getText().toString().trim();
Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse(nber));
startActivity(callIntent);
And give Manifest permission
<uses-permission android:name="android.permission.CALL_PHONE" />
Intent calltoDoctor = new Intent(Intent.ACTION_CALL);
calltoDoctor.setData(Uri.parse("tel:" + personalInformation.getEmgyno()));
startActivity(calltoDoctor);
Add the permission in manifest.
<uses-permission android:name="android.permission.CALL_PHONE" >
try this

How to send MMS from Android App?

I am working on a project where I need to send MMS from my android app. Below is the code which I tried but it is not working. Please advise.
Intent mmsIntent = new Intent(Intent.ACTION_SENDTO);
mmsIntent.addCategory(Intent.CATEGORY_DEFAULT);
mmsIntent.setType("vnd.android-dir/mms-sms");
mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));//Uri.parse(url));
mmsIntent.setData(Uri.parse("sms:" + "89565656"));
startActivity(mmsIntent);
check this:
Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","9876543211");
i.putExtra("sms_body","hello..");
i.putExtra(Intent.EXTRA_STREAM,Uri);
i.setType("image/png");
startActivity(i);
Here Uri is:
Uri uri = Uri.parse("content://media/external/images/media/1");
or
Uri uri = Uri.parse("file://mnt/sdcard/test.jpg");
or
Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.jpg");
For me below code is working perfect.....
Intent smsIntent = new Intent(android.content.Intent.ACTION_SEND);
smsIntent.putExtra("sms_body", mContext.getString(R.string.app_name));
smsIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + imagePath));
smsIntent.setType("image/png");
mContext.startActivity(smsIntent);

How to send a message in android 2.2?

I want to send a message (sms/mms) with android 2.2. First I made an intent chooser with an ACTION_SEND to select which to use :
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, Resources.getString("InvitationSubject", getBaseContext()));
String body = Resources.getString("InvitationBody", getBaseContext()) + Local.User.FirstName;
intent.putExtra(Intent.EXTRA_TEXT, body);
startActivity(Intent.createChooser(intent, "Invite friends"));
But in that case, the selector show 'Bluetooth, Messaging, Google+, Gmail'. I want to show ONLY Messaging or other messaging apps.
I saw in the sdk docs there's a new CATEGORY_APP_MESSAGING to use but it's only available in the API level 15. I have to keep API level 8. Is there a way to do that ?
Try this code
String body = Resources.getString("InvitationBody", getBaseContext()) + Local.User.FirstName;
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.putExtra("sms_body", smsBody);
sendIntent.setType("vnd.android-dir/mms-sms");
startActivity(sendIntent);
Don't forget to add this <uses-permission android:name="android.permission.SEND_SMS" /> in your manifest.
You can use the type mms-sms, like so
intent.setType("vnd.android-dir/mms-sms");
use following code to send message
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "message subject");
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, "text");
startActivity(Intent.createChooser(shareIntent, "Pick a Share method"));
Gives following permission
<uses-permission android:name="android.permission.SEND_SMS" />

Categories

Resources