• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps intent passing null value

pa1teja

Lurker
hello,

I'm a beginner at developing android applications,and I'm stuck at a place trying to send data from mainActivity to another activity using intents. and right before putting the variable in the intent.putExtra() method ,I've checked if the variable contains data using println statement and it displayed the content in that variable but right after getting the data from the intent into the next activity and it is showing null when checked for contents in that variable using println statement.

this is my code :

mainActivity:
Java:
if (propertyInfo.name.contains("shopName")) {
                        String shopName = propertyInfo.getValue().toString();
                        System.out.println("shopName to be sent in intent : " + shopName); //value is being displayed here.
                        intent.putExtra("shopName",shopName);


if (propertyInfo.name.contains("shopNo")) {
                        String shopNo = propertyInfo.getValue().toString();
                        System.out.println(" shopNo to be sent in intent :" + shopNo);// value is being displayed here.
                           intent.putExtra("shopNo", shopNo);
}
second Activity:
Java:
  Intent intent = getIntent();




        String shopNameS = intent.getStringExtra("shopName");
        System.out.println("shopName is : " +shopNameS); // null is being displayed
        shopName.setText("(" + shopNameS + ")");

        String shopNumberS = intent.getStringExtra("shopNo");
        System.out.println("shop number is : " + shopNumberS); // null is being diaplayed      
        shopNumber.setText(shopNumberS);

please help me resolve this problem

thank you,
 
Last edited by a moderator:
Hi @pa1teja and welcome to AF :)

I'm no developer, so I can't really help with your issue - but I can (and did!) wrap your code snippets in [code=java]...[/code] tags to make it a bit easier to read. Hopefully that will help a real developer help you out. :thumbsupdroid:

Good luck!
 
Back
Top Bottom