Vcard sent as plain text - android

I have generated a vcard of the selected contact. I am sending it through sms (though i know we could send it through mms, but there are some phones that dont support mms).
when I am sending it to another phone, the exact string is received as such,
BEGIN:VCARD
VERSION:2.1
N:Mahajan;Sahil;;;
FN:Sahil Mahajan
TEL;HOME:964-695-7130
EMAIL;HOME:sahilmahajanmj#gmail.com
END:VCARD
But I want that on receiving this message, there should be a default option of saving it as contact.
I am sending it using the following code,
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(mobileNumber, null, vCardString, null, null);
here vCardString is the actual string containing the vcard. Let me know, if i need to post anything else.

Related

How can I send SMS from one number to another number in android programatically?

I am developing an android application. It requires to send text message (i.e.SMS) for OTP(One Time Password) purpose to user so he/she can enter the valid OTP code and get logged in to application.
I was looking at SMSManager API provided by android framework which uses to send text messages from application itself. But I need to send a text message from my registered number to user.
How can we achieve this requirement?
If you want to send sms via your application this is the way.
SmsManager.getDefault() - get default instance of SmsManager
sendTextMessage(String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
Use this to send the SMS
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, sms, null, null);
don't forget
<uses-permission android:name="android.permission.SEND_SMS" />
check this link for more info if required

How to send SMS from the Android app without making its record in device SMS view?

I want to send an SMS from my android app. But I don't want its record to be exist in device message view. I am currently using below code.
sendSMS(etsendernumber.getText().toString(), etmessagebody.getText().toString());
sendintent = new Intent(Intent.ACTION_VIEW);
sendintent.putExtra("sms_body","");
sendintent.setType("vnd.android-dir/mms-sms");
startActivity(sendintent);
But it is making sent sms record in message view of the device. Can we send a secret sms from android application?
Please advice.
Yes, the way you are trying to send SMS is by using the shipped messaging application. So it will always record the sent messages. You must use SmsManager to send the SMS.
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, null, null);
In this way, your SMS wont be inserted into the list.
Also remember to add this in your manifest
<uses-permission android:name="android.permission.SEND_SMS" />
If you use android SMS application to send message then it would save that message in the outbox or sent. What you can do is delete that message from the sms database.
After sending sms Delete that message using this:
getContentResolver().delete(Uri.parse("content://sms/outbox"), "address = ? and body = ?", new String[] {etsendernumber.getText().toString(),etmessagebody.getText().toString()});
If msg is in out box
OR
getContentResolver().delete(Uri.parse("content://sms/sent"), "address = ? and body = ?", new String[] {etsendernumber.getText().toString(),etmessagebody.getText().toString()});
If message is in sent items.

Android: How to send SMS to email account

The stock Android text messaging app allows you to send SMS to an email account instead of a phone number. How is this done? I tried the following code and it failed.
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("myaccount#gmail.com", null, textMsg, sentPI, null);
This other question seems to be related How to send SMS message reply to email address?
... but the accepted answer says
Each cell carrier has a specific SMS number that you can send a text message to in a certain format. This is called a "SMS Gateway".
I want to send to my gmail account, not to AT&T.
Sorry, seems I misread the answer. Looks like my carrier (AT&T) will send the email for me. What puzzles me is how an app could work for different carriers?

SmsManager with Email Address as Destination - NullPointerException

My cellphone carrier offers an sms-email gateway. This is done simply by entering the email address as the SMS message's destination. The email is delivered as 5555555555#mycarrier.com
I am attempting to use this with my new Android device. The standard android messaging application converts all messages with an email address as the destination to "MMS" and attempts to send them as data - not what I want to do.
Attempting with android.telephony.SmsManager:
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage("address#example.com", null, "Message body here", null, null);
This throws the following exception:
Caused by: java.lang.NullPointerException
at com.android.internal.telephony.gsm.SmsMessage.getSubmitPduHead(SmsMessage.java:595)
at com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(SmsMessage.java:295)
at android.telephony.SmsMessage.getSubmitPdu(SmsMessage.java:599)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:228)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:107)
I've looked at this project, android-sms-email, which attempts to do the same thing. It also crashes in the same fashion when configured for my carrier.
This does not seem like the desired behaviour and I assume it is an Android bug (some bug reports hint at the issue). I've experimented a bit and can see that appending any number and some symbols to the email address do not cause the same failure but the message is not delivered either.
I've also tried using SmsManager.sendMultipartTextMessage but this runs into the same problem within SmsMessage.getSubmitPduHead.
Again:
SmsManager manager = SmsManager.getDefault();
// Works
manager.sendTextMessage("15555555555", null, "Message body here", null, null);
// Fails
manager.sendTextMessage("address#example.com", null, "Message body here", null, null);
Tested on an HTC Desire Z - Android v2.2
Please check this articles.
Programatically send SMS to email using Verizon Motorola Droid on Android
How to send SMS message reply to email address?
You should know the SMS gateway number of the carrier and make a message like this:
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage("6425", null, "username#domain.com (Subject) message text", null, null);
Verizon wireless-> 6425, AT&T mobility -> 121 111
I've issued a bug report: http://code.google.com/p/android/issues/detail?id=16934

Is it possible to read and/or modify the SMS header on Android?

I am developing an Android application for 1.6 and above that sends and receives SMS messages through a port.
To send the SMS I am using the method:
SmsManager.sendDataMessage(String destinationAddress, String scAddress, short destinationPort, byte[] data, PendingIntent sentIntent, PendingIntent deliveryIntent)
but have discovered that the byte[] data should contain only the message body. There seems to be no method available to send multi-part data messages and no way of modifying the SMS header (UDH) to specify that the messages is, say, 1 of 3.
I'm having a similar problem on the receiving end when trying to extract the message count information from the SMS I have received through the specified port. I am using SMSMessage.getPdu() to extract a byte[] containing the message header and message body but have no way of extracting the specific information from the header data.
Does anyone know the format the Android platform uses for SMS headers?
You will need to check 3GPP SMS spec. For me, I got the destination port info from 30th and 31st byte.

Categories

Resources