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

how 3.2<= pick the right layout?
Android Parsing Google Places JSON data using location-based latitude & longitude
Does anyone know what the output from getevent means?
NullPointerException when using Spring RestTemplate in Android
When I load the image in the folder “drawable” - have different image sizes
Which android tab supports v4L2 with USB host functionality?
hls in html5 not working in android chrome browser
What should the Android device ID length be
android play store updates and reversion
How to show textview at bottom over imageview when size unknown
What is the best practice for naming the id of XML Element in Android?
how to have the possibility to chose between the frequency of the locationupdates(every seconds,minutes etc..)?
progress dialog that doesn't work with log out in android
When upload image file to wcf from android, the image file is broken
To create a fragment that holds a view, must one always override the Fragment class
Android SDK preference in eclipse

Categories

HOME
developer-tools
time-complexity
nvd3.js
google-spreadsheet
flex
mstest
jelastic
vsm
tvos
lanczos
character
okhttp
32bit-64bit
categorical-data
appcelerator-studio
siddhi
parameter-passing
symfony-2.8
red5
video-editing
sigma.js
bourbon
asp.net-core-webapi
roslyn
visual-studio-extensions
highstock
draft-js-plugins
fat
jasmine-node
nstimer
oculus
bioinformatics
carrierwave
google-cast
zend-debugger
erb
sammy.js
login-script
numpy-broadcasting
protege4
raft
node-mssql
recurrent-neural-network
urlsession
datacachefactory
tcc
memory-mapping
servermanager
xbmc
hammer.js
mongotemplate
google-cse
subnet
rxtx
juice-ui
materialized-path-pattern
pytables
microstation
model-associations
installshield-2010
pre-build-event
httpruntime.cache
piracy-prevention
vhosts
character-replacement
roadkill-wiki
alloy-ui
node-serialport
jquery-forms-plugin
user-permissions
public-html
android-vibration
device-tree
mintty
jquery-slider
draw2d-js
websphere-esb
ora-06550
tlf
pagedown
traceability
video-codecs
android-sdk-2.3
idn
onmousemove
thttpd
blender-2.49
leader
netbeans6.1

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