-1

I have created a library project with one activity. I have given reference of this library project to my Main Project. I am trying to call Activity of Library Project with some extras through intent. But I am getting null pointer exception while retrieving getIntent.getExtras in Library Project. Any idea how to do this?

I am starting activity of Library Project like below:

    Intent intent = new Intent(activity,com.***.***.LibActivity.class);
    intent.putExtra("key", "abcds");
    activity.startActivity(intent);

And I am trying to retrieve the key in LibActivity (Which is in library project) like below:

getIntent().getExtras().getString("key") -->Throwing null pointer exception at this line

I have added this activity to my Main Projects manifest.

Rakesh
  • 19
  • 1
  • 3
  • 1
    Post your code and logcat.. – Tarun Aug 19 '13 at 07:34
  • Do you have the library activity listed in the manifest of your main project? – David Wasser Aug 19 '13 at 07:41
  • I am starting activity of Library Project like below: Intent intent = new Intent(activity,com.***.***.LibActivity.class); intent.putExtra("key", "abcds"); activity.startActivity(intent); And I am trying to retrieve the key in LibActivity (Which is in library project) like below: getIntent().getExtras().getString("key") -->Throwing null pointer exception at this line I have added this activity to my Main Projects manifest. – Rakesh Aug 19 '13 at 08:23

1 Answers1

-1

You have to pass this on your main project

Intent myIntent= new Intent(this,YourActivity.class);
myIntent.putExtra("shopId", shopId);
this.startActivity(myIntent);

And in your Library activity You have to pass just this

String intentdata = this.getIntent().getStringExtra("shopId");

Then boom your work is done!

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Prakash
  • 9
  • 2