diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java index c4e0d0093..7436d38be 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepActivity.java @@ -420,8 +420,10 @@ public class GuidedStepActivity extends Activity { boolean isPaymentValid() { CharSequence paymentType = findActionById(PAYMENT).getDescription(); - return paymentType.subSequence(0, 4).toString().equals("Visa") || - paymentType.subSequence(0, 6).toString().equals("Master"); + return (paymentType.length() >= 4 && + paymentType.subSequence(0, 4).toString().equals("Visa")) || + (paymentType.length() >= 6 && + paymentType.subSequence(0, 6).toString().equals("Master")); } boolean isPasswordValid() { diff --git a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java index 09eed7922..189db8946 100644 --- a/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java +++ b/samples/SupportLeanbackDemos/src/com/example/android/leanback/GuidedStepSupportActivity.java @@ -422,8 +422,10 @@ public class GuidedStepSupportActivity extends FragmentActivity { boolean isPaymentValid() { CharSequence paymentType = findActionById(PAYMENT).getDescription(); - return paymentType.subSequence(0, 4).toString().equals("Visa") || - paymentType.subSequence(0, 6).toString().equals("Master"); + return (paymentType.length() >= 4 && + paymentType.subSequence(0, 4).toString().equals("Visa")) || + (paymentType.length() >= 6 && + paymentType.subSequence(0, 6).toString().equals("Master")); } boolean isPasswordValid() {