Search code examples
androidandroid-edittextpasswordsmirroring

How can I show a mirrored Android screen when I type a password?


I am using "Mobizen Mirroring" to mirror the screen of my smartphone.
I'm trying to enter a password within the smartphone app through a mirrored computer.
However, pressing the password "EditText" turns the mirrored computer screen black.
I should see my password on the mirrored computer screen.
https://i.sstatic.net/nIMkg.png

I changed the value of the EditText property.

android:inputType="textPassword"
android:inputType="textVisiblePassword"

and search keyword like mirroring, mobizen, password, edittext, etc...
But I can't found any post like my problem

The EditText code looks like this:

EditText

<EditText
        android:id="@+id/password_edit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="password"
        android:inputType="textPassword"
        android:textAppearance="@style/TextAppearance.AppCompat.Large"
        android:visibility="visible" />

When I click the "EditText", I should be able to see the output of the mirrored computer.
Maybe it's a security policy.
Should I make it a plain EditText without a password attribute?


Solution

  • You can change the inputType to text and add your own transformationmethod like this:

    edittext.setTransformationMethod(new MyPasswordTransformationMethod());
    
    public class MyPasswordTransformationMethod extends PasswordTransformationMethod {
    @Override
    public CharSequence getTransformation(CharSequence text, View view) {
        return new PasswordCharSequence(text);
    }
    
    private class PasswordCharSequence implements CharSequence {
        private CharSequence mText;
        public PasswordCharSequence(CharSequence text) {
            mText = text; 
        }
        public char charAt(int index) {
            return '*'; 
        }
        public int length() {
            return mText.length(); 
        }
        public CharSequence subSequence(int start, int end) {
            return mText.subSequence(start, end);
        }
    }
    };