android


Android: How to include phone number on Intent.createChooser activity for native SMS option


I'm trying to implement sending an SMS from an Android app with a predefined text message. I'm using the native chooser activity by doing:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
String[] phoneNumber = {selectedContact.getPhoneNumber()};
intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.contact_message_body));
intent.putExtra(Intent.EXTRA_PHONE_NUMBER, phoneNumber);
startActivity(Intent.createChooser(intent, "Send Message"));
The phone number is indeed stored in the phoneNumber variable, but when testing it, it's not being passed over to the recipient field for the Messages option. So the EXTRA_TEXT info fills the new SMS but the recipient is empty.
I've seen others use Intent.ACTION_SEND but this will not work in my case, because I also have to implement Email sending from the same chooser.
Appreciate the help!
Did you try to use SmsManager I think it's more easy to use
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("phoneNo", null, "sms message", null, null);

Related Links

Why a ListView automatically unselect selected items?
I want to call Default camera using “MediaStore.ACTION_IMAGE_CAPTURE” and start default camera in focus mode “MACRO”
TextView Marquee Doesn't Work
What does .draw() does in achartengine?
SharedPreferences.Editor.commit()
Sorting a ArrayList<HashMap<String, String>> by a date range
How to added customed jar into my android project ? (I added core.jar into my android project but still class not find exception.)
ListView in AlertDialog is repeated
The world of Listview
Threading android doubts
Realtime Chart on Android using ChartDroid(or Any)
How can i Confirm request to friend?
Android mapview bigger zoom
Class definition for twitter4j.TwitterFactory not found
Sending bulk sms to clients. what kind of data storage should i prefer?
How to get extended Android software version?

Categories

HOME
google-app-engine
xml
search
adal
merge
swt
saml-2.0
apiblueprint
package
yandex
simulink
scripting
permissions
jquery-ui
code-coverage
azure-container-service
nstableheaderview
g++
vimdiff
reactive-programming
watson-conversation
jxl
rtf
renjin
symmetricds
gource
gruntfile
keytool
internationalization
dreamweaver
fileserver
sse
oledb
systemtime
displaytag
dapper-extensions
maze
fable-f#
licensing
jackson-modules
has-and-belongs-to-many
mat
android-maps
firebase-analytics
custom-controls
eviews
aws-codecommit
xbox
livelink
testbed
clickjacking
papaparse
openproject
amazon-ses
verifiable-c
metawidget
magento-1.9.3
laravel-elixir
claims
bindingnavigator
avcapturedevice
getchar
automapper-5
clarifai
truezip
sundials
arules
jtree
structuremap4
sandcastle
stripe-connect
winusb
swizzling
nupic
phpgrid
jnlua
tfs-workitem
rpart
ember-cli-rails
lasso
nsurlsessiondatatask
uvc
execve
uncaught-typeerror
primitive-types
sonarqube-5.0
teaspoon
trdion2011
grails-plugin-rabbitmq
vsx
vbe
synapse
android-audiorecord
accesscontrolexception
away3d
jeromq
ice-cube
traceability
onmousemove
failing-tests
screen-size
catransform3d
update-statement
drupal-fivestar
tui
fail-fast-fail-early
dsoframer
great-circle

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App