Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:&quo

code for validating the credit card number in Android

EditText cardNumber=(EditText)findViewById(R.id.cardNumber);
        String CreditCardType = "Unknown";
       
       /// Remove all spaces and dashes from the passed string
        String CardNo ="9292304336";///////cardNumber.getText().toString();           
        CardNo = CardNo.replace(" ", "");//removing empty space
             CardNo = CardNo.replace("-", "");//removing '-'
              twoDigit=Integer.parseInt(CardNo.substring(0, 2));
                                 System.out.println("----------twoDigit--"+twoDigit);
              fourDigit=Integer.parseInt(CardNo.substring(0, 4));
                                 System.out.println("----------fourDigit--"+fourDigit);
             oneDigit=Integer.parseInt(Character.toString(CardNo.charAt(0)));
                                System.out.println("----------oneDigit--"+oneDigit);
           
             boolean cardValidation=false;
            // 'Check that the minimum length of the string isn't <14 characters and -is- numeric
             if(CardNo.length()>=14)
             {
               
                 cardValidation=cardValidationMethod(CardNo);
               
             }

 boolean cardValidationMethod(String CardNo)
     {
        //'Check the first two digits first,for AmericanExpress
        if(CardNo.length()==15 && (twoDigit==34 || twoDigit==37))
        return true;
        else
            //'Check the first two digits first,for MasterCard
            if(CardNo.length()==16 && twoDigit>=51 && twoDigit<=55)
                return true;
        else
            //'None of the above - so check the 'first four digits collectively
                if(CardNo.length()==16 && fourDigit==6011)//for DiscoverCard
                return true;
        else
           
            if(CardNo.length()==16 || CardNo.length()==13 && oneDigit==4)//for VISA
                return true;
            else
                return false;       
     }

Comments