Why am i getting garbage values as my output using this android-lockpattern library?

StackOverflow https://stackoverflow.com/questions/22764039

  •  24-06-2023
  •  | 
  •  

Вопрос

I am using the android lock pattern library for a project of mine when I print the output pattern in a toast I get all garbage values like [C245faa3a8

I got the library and the code from https://code.google.com/p/android-lockpattern/

here is my code.

public class PatternTest extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        // This is your preferred flag

        Intent intent = new Intent(LockPatternActivity.ACTION_CREATE_PATTERN,
                null, getBaseContext(), LockPatternActivity.class);
        startActivityForResult(intent, REQ_CREATE_PATTERN);
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        char[] pattern = null;
        switch (requestCode) {
        case REQ_CREATE_PATTERN: {
            if (resultCode == RESULT_OK) {
                pattern = data
                        .getCharArrayExtra(LockPatternActivity.EXTRA_PATTERN);

            }
            break;
        }// REQ_CREATE_PATTERN
        }
        Toast.makeText(getApplicationContext(),pattern.toString(),
                Toast.LENGTH_LONG).show();
    }
}
Это было полезно?

Решение

use new String(byte[]) instead of toString():

 Toast.makeText(getApplicationContext(),new String(pattern),
            Toast.LENGTH_LONG).show();
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top