how to read user login using space android

helloo

New Member
i want to make a login process in my aplication, the user name is using space, how to read the user names that using space..? this is my support class for validation login process :\[code\]public class validator {public static boolean emailValidator(String email) { boolean isValid = false; String expression = "^[a-zA-Z0-9\\s]+$"; CharSequence inputStr = email; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(inputStr); if (matcher.matches()) { isValid = true; } return isValid;}public static boolean isNotEmptyValidator (String strValue,int intMinLength){ if(strValue.length() < intMinLength) return false; else return true;}\[/code\]}this is the login process :\[code\]public class LoginAsyncTask extends AsyncTask<Void, Integer, Void> { int myProgress; String str2=""; @Override //POST protected void onPostExecute(Void result) { // TODO Auto-generated method stub Log.v("Login Result > ",str2+";"); if(str2.equals("xx") || str2.equals("") || str2.equals(null)) { AlertDialog.Builder builder = new AlertDialog.Builder(Login.this); builder.setTitle("Login Gagal"); builder.setMessage("User ID atau password salah."); builder.setPositiveButton("Coba Kembali", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { etPass.setText(""); etPass.findFocus(); ivLogInButton.setClickable(true); rlLoading.setVisibility(View.GONE); } }); builder.setNegativeButton("Keluar",new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent itSplashEnd = new Intent(Login.this, SplashEnd.class); itSplashEnd.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); itSplashEnd.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(itSplashEnd); finish(); } }); builder.create().show(); } else { try { File root = new File( Environment.getExternalStorageDirectory() + strStoragePath); if (!root.exists()) { root.mkdirs(); } File gpxfile = new File(root, strFileDiv); FileWriter writer = new FileWriter(gpxfile); writer.append(str2); writer.flush(); writer.close(); finish(); Intent itMainMenu = new Intent(Login.this, MainMenu.class); itMainMenu.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); itMainMenu.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(itMainMenu); } catch(IOException e) { //Log.v("generateNoteOnSD()", "Error " + e); } @Override //PRE protected void onPreExecute() { myProgress = 0; } @Override protected Void doInBackground(Void... params) { try { // Create a URL for the desired page publishProgress(20); String strUser = etUser.getText().toString(); String strPass = etPass.getText().toString(); byte[] data = http://stackoverflow.com/questions/15893070/strPass.getBytes("UTF-8"); strPass = Base64.encodeToString(data, Base64.DEFAULT); String strUrlLoginFullpath = ""; strUrlLoginFullpath = strUrlMain+ "exl?u="+strUser+"&p="+strPass+"&t=1"; URL url = new URL(strUrlLoginFullpath); publishProgress(40); URLConnection urlConn = url.openConnection(); urlConn.setConnectTimeout(50000); urlConn.setReadTimeout(50000); BufferedReader in = new BufferedReader( new InputStreamReader( urlConn.getInputStream())); publishProgress(60); String inputLine; int i=0; while ((inputLine = in.readLine()) != null) { Log.v("Login",i+", return:" +inputLine+"; url: "+strUrlLoginFullpath); if(i == 5) { Log.v("Login","RESULT >"+i+", return:" +inputLine+"; url: "+strUrlLoginFullpath); str2 = inputLine; } i++; } in.close(); publishProgress(80); publishProgress(100); } catch (MalformedURLException e) { Log.v("KxL", "MalformedURLException=" + e.toString()); } catch (IOException e) { Log.v("KxL", "IOException=" + e.toString()); } return null; } protected void onProgressUpdate(Integer... values) {\[/code\]}i hope somebody can help me to solve this problem, thanks
 
Top