• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

Why is the string value null when passed from activity to broadcast receiver?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am passing a value from activity to broadcast receiver:

My activity code:

 



My broadcast receiver code:

   

As you can see the key is same in both the cases, still the value is returned null in my broadcast receiver, when passed from the activity. Why?

Is there any other way of passing the value from activity to broadcast receiver?

**EDIT :** I've tried declaring the

stringBuilder

variable as , in the activity, but still it shows null when accessed from broadcast receiver class.
 
Rancher
Posts: 4316
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried printing out the contents of the Intent and the Extras it may contain?
Is there a Bundle there that has the desired value?
 
Abhishek Roychoudhury
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:Have you tried printing out the contents of the Intent and the Extras it may contain?
Is there a Bundle there that has the desired value?



Yes, I can only fetch the action attached with the intent, but the string value that I attached is null.
 
Norm Radder
Rancher
Posts: 4316
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What was printed on the logcat when you printed out the contents of the intent before the call to sendBroadcast and in the onReceive method?
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic