Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

intent.putExtra() question  RSS feed

 
Ranch Hand
Posts: 62
2
Java Mac Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been reading through This tutorial on www.developer.android.com.  All I need to do is copy the code but I'm having a problem with the code below.   I have no idea what the EXTRA_MESSAGE is for.  Its giving a an error anyway so I'm guessing I must change it to something else?  I was reading something about my package name goes there but that also doesn't work.  Thanks.

 
Saloon Keeper
Posts: 5496
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You only need putExtra if you want to pass additional data to the new activity. If not, you can omit it.
 
Ranch Hand
Posts: 570
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The EXTRA_MESSAGE is the string you need to bring to next activity.

You can write like this



To get the string message in DisplayMessageActivity, you have to write in this way


 
Ranch Hand
Posts: 491
10
Android Open BSD Slackware
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OP consider that in real life scenario( but even simple tutorials) you could like to use as well onActivityResult   onActivityResult
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you declared EXTRA_MESSAGE ? It has to be a variable of type string, or you should include it inside of quotes "EXTRA_MESSAGE" , then you will not get the compilation error
 
It will give me the powers of the gods. Not bad for a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!