Like getIntent().getIntExtra, does getStringExtra have a default value which can be used if the string passed is empty?
I have a method to do this, but was wondering if there was an existing for achieving it to?
Thanks.
We cannot check if it is empty, but we can check it by comparing it with null.
str = intent.getStringExtra("key");
if(str == null){
str = "DEFAULT STRING";//Assign default string
}
According to http://developer.android.com/reference/android/content/Intent.html, no.
The reason getIntExtra has a default value parameter, it is because the type returned is a primitive and therefore can't return null.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With