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

Apps Trouble with UUID

OmerK

Lurker
Hey, I am new here :).

I have some problems with putting an extra in a fragment (UUID - thats defined in the class Recepie) and retracting that UUID in another fragment.

for some reason, when I put the extra (UUID) with the Extra_Recepie_ID string,
I put a one string. (FragmentListRecepie)

when I want to retract that UUID, I get a different UUID. (FragmentRecepie)

Your help please!

public class Recepie {
private UUID mId;

public Recepie()
{
mId=UUID.randomUUID();
isFavorite = false;
}

public UUID getId() {
return mId;
}
...
}

RecepieListFragment

public void onListItemClick(ListView l, View v, int position, long id)
{
Recepie c = ((RecepieAdapter)getListAdapter()).getItem(position);
Intent intent = new Intent(getActivity(),Cook_book_activity.class);
intent.putExtra(RecepieFragment.Extra_Recepie_ID, c.getId());
startActivity(intent);
}

RecepieFragment

public class RecepieFragment extends Fragment {
public static final String Extra_Recepie_ID= "Cook.Book.Extra_ID.Attampt";
private Recepie mRecepie;
private EditText notes;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
UUID recepieID = (UUID)getActivity().getIntent().getSerializableExtra(Extra_Recepie_ID);
mRecepie = RecepieDatabase.get(getActivity()).getRecepie(recepieID);
}
 
Maybe try converting the UUID to String before putting it in the Extra?

Did you log the UUID in onListItemClick then log it again in onCreate ?
 
Thanks but the problem was someplace else.

I am new to Android programming and the problem was that I compared using (==) and not the equals method. thus it seemed as f the UUID changed.

thanks though
 
Back
Top Bottom