Hi I am a beginner to programming. I am trying to learn Android development from udacity.
Cursor cur = someFunction();
if(cur != null){
Intent intent = new Intent(getActivity(), two.class);
intent.setData(cur.getLong(2));
startActivity(intent)
}
Now in two class.
Intent intent = getActivity.getIntent();
if(intent != null){
mString = intent.getDataString();
}
if(null != mString){
mTextView.setText(mString);
}
I was just wondering why do we require so many ifs in this code. The if in first piece of code is fine.
When the second activity was called from first activity. Why do we need to check if the intent is null? Since it is the only entry point to the second activity.
And why do we again need to check if the string is null before assigning it to Text View?
Aucun commentaire:
Enregistrer un commentaire