android


Two EXTRA_MESSAGE from Intent


Can i have two extra messages on Intent that i can pass on another Activity? If yes, how does it work?
this is what I did:
Intent intent3 = new Intent(this, Start.class);
String message = o.getName();
String messages = o.getPath();
intent3.putExtra(EXTRA_MESSAGE, message);
intent3.putExtra(EXTRA_MESSAGE, messages);
startActivity(intent3);`
and on the Activity that will receive the message:
Intent intent3 = getIntent();
String message = intent3.getStringExtra(Browse.EXTRA_MESSAGE);
String messages = intent3.getStringExtra(Browse.EXTRA_MESSAGE);`
You have to change the KEY:
Intent intent3 = new Intent(this, Start.class);
String message = o.getName();
String messages = o.getPath();
intent3.putExtra(EXTRA_MESSAGE, message);
intent3.putExtra(EXTRA_MESSAGE_TWO, messages);
startActivity(intent3);
Not exactly like that, but it is easy to send multiple values. The first parameter to putExtra or getStringExtra is a key into a map of values so it must be unique. As long as you use a different key for each value you can put as many as you want in the intent.
For example:
Intent intent3 = new Intent(this, Start.class);
String message = o.getName();
String messages = o.getPath();
intent3.putExtra("name", message);
intent3.putExtra("path", messages);
startActivity(intent3);
Intent intent3 = getIntent();
String message = intent3.getStringExtra("name");
String messages = intent3.getStringExtra("path");`
This is a problem the way you have them. You need separate keys for each value. So for example
intent3.putExtra("msg1", message);
intent3.putExtra("msg2", messages);
then in your receiving Activity you can get them using the above keys. But you can add as many Extra values as you want.
Two different keys and messages will do it
Intent intent3 = new Intent(this, Start.class);
String message = o.getName();
String messages = o.getPath();
intent3.putExtra(EXTRA_MESSAGE1, message);
intent3.putExtra(EXTRA_MESSAGE2, messages);
startActivity(intent3);

Related Links

android.view.WindowLeaked on Asyctask
Why the title of TableLayout are always show in capital letters? [duplicate]
how to put icons for the string array
Android Spinner Adapter Now working
Android : gson.toJson() doesn't give standard json
Android:How to get status code 200 OK in Webview?
Unhandled Exception in Xamarin Android When Using HttpWebResponse
startActivityForResult, result not within main thread
how can an Activity get interface calls from its adapter
How to display live streaming (http video) in android
Optimese performance of contact listing
Get email and phone no of name defined without using pick intent
How to set different percentages for Mobile & Tablets
How to check if a view has children
How to debug a CHOOSER action in Android?
Firebase Analytics does not work in my app

Categories

HOME
url-redirection
httparty
oracle12c
linkedin
ng-idle
pagination
gpu
tivoli
barcode
bing-maps
startup
alamofire
favicon
gruntfile
event-sourcing
intershop
vuejs
google-container-registry
bourbon
selinux
drive
kendo-mobile
pimcore
interpreter
amazon-quicksight
oculus
openmdao
calculation
corenlp-server
event-flow
livelink
complex-numbers
deltaspike
contacts
batching
apic
cd
timing
bc
trigonometry
datacachefactory
parser-generator
naming
claims
bindingnavigator
placeholder
plan-9
dynamic-linq
stdmap
colorbar
edit
usart
cudd
angular2-testing
winusb
webjars
windows-azure-queues
jodd
model-associations
scaffolding
tooleap
mediametadataretriever
phpgrid
linklabel
opl
forwarding
zscript
baasbox
iiop
browserify-shim
functional-java
extjs2
openargs
dolby-audio-api
pclzip
web-notifications
android-loadermanager
midlet
objectquery
fusefabric
failing-tests
virtualpathprovider
xui
cuteeditor
django-paypal
socketserver
duplex
wysiwym
business-model
wcf-proxy
leader

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