Your problem is that you are trying to access extras
in your Intent
but you aren't passing any. You do in the Intent
below which is why that one works
intent.putExtra("picture", b);
but you don't do this in your other onClick()
. You will either make sure that you are sending extras
or to be safe do a null
check in your SecondActivity
with something like
Bundle extras = getIntent().getExtras();
//line18
if (getIntent().getExtras() != null)
{
byte[] b = extras.getByteArray("picture");
}
Then of course you will need to handle the lines below that if it is null
.
Edit
If the two Button
s will do generally the same thing then you can See this answer to use the same method for both. Then you just switch
on the id
of the View
to use different code depending on which was clicked. Something like
@Override
public void onClick(View v) { // arg0 is an ugly name for a param so I changed it to v
switch (v.getId())
{
case (R.id.Floaterimg):
// do stuff if this image is clicked;
break;
case (R.id.journbtn):
// do stuff if this image is clicked;
break;
}
}
then put common code such as your Intent
outside of the switch
statement.