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

Can't open file from internal storage. Code crashing in Android 7.1
Textview created in onPostExecute() not displayed in emulator
Use a RingtonePreference in PreferenceFragmentCompat?
Issue with Context when trying to create an instance of custom adapter class
Is there a way to copy all personal files at once? android
Getting orientation of user prompted image is not working
Android FCM Push Notification not received when app is closed
Purchase Check/Auth for Paid Apps
Strange IndexOutOfBoundsException when accessing SharedPreferences
Google Maps API isn't loading map
How can stream data received from a USB serial port in Android?
activity background image from url android studio
why android ACTION_UUID returns wrong object
How to underscore the email and password edittext fields?
Listview to ViewHolder method
How does android merge the custom library's support library with that of application? [duplicate]

Categories

HOME
adal
checkstyle
deep-learning
polymer
codenvy
nvd3.js
apache-jena
ecmascript-6
phpmyadmin
character-encoding
grafana
rendering
carousel
switch-statement
echo
jtextpane
endeca
text-mining
x-cart
naivebayes
eip
flash-player
internationalization
dimensional-modeling
jersey-1.0
bourbon
babel
object-storage
xcode-ui-testing
licensing
flooding
datastax-enterprise-graph
ceylon
vex
realm-mobile-platform
kudu
cart
python-import
jwplayer6
slacktextviewcontroller
sql-delete
getlasterror
roblox
searchkit
sessionstorage
flatmap
android-augmented-reality
railstutorial.org
plaintext
ssrs-2014
android-exoplayer
strftime
flask-restful
builder
hammer.js
spring-integration-sftp
reportservice2010
payara-micro
opengl-4
quicktime
lsyncd
trigger.io
baidu
cudd
pure-css
qtplugin
windows-azure-queues
model-associations
expectations
tooleap
hadoop-partitioning
uiactionsheet
jdi
ember-cli-rails
lasso
finalbuilder
jsvc
dnssec
gamekit
packet-sniffers
post-commit-hook
spy++
punycode
psr-4
mobility
jquery-slider
square-bracket
high-resolution
kogrid
ui-select2
poker
preload
bjyauthorize
redis-py
onmousemove
httponly
flex-mobile
listactivity
cgbitmapcontextcreate
dataform
cdonts
build-environment
appliance

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