How to implement app to work with Samsung Pass?

Viewed 398

I am trying to write simple app which uses Samsung Pass and/or Google Auth, but both of them doesn't work despite of proper settings on my device. Popup for saving password and username doesn't show. Other apps works good on my device with Samsung Pass/Google Auth.

Below my layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:importantForAutofill="yes"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/username"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:autofillHints="username"
        android:hint="username"
        android:inputType="text"
        android:importantForAutofill="yes" />

    <EditText
        android:id="@+id/password"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:autofillHints="password"
        android:hint="password"
        android:importantForAutofill="yes"
        android:inputType="textPassword" />

    <Button
        android:id="@+id/loginButton"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="Zaloguj"
        app:layout_constraintTop_toBottomOf="@+id/password" />

</LinearLayout>

and activity:


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        loginButton.setOnClickListener {
            if (checkCredentials(username.text.toString(), password.text.toString())) {
                val intent = Intent(this, LoggedInActivity::class.java)
                startActivity(intent)
            }
        }
    }

    private fun checkCredentials(username: String, password: String): Boolean {
        return (username.isNotEmpty() && password.isNotEmpty())
    }
}

What am I doing wrong?

1 Answers

Ok, found the reason - finish() must be called after starting new activity.

    override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    loginButton.setOnClickListener {
        if (checkCredentials(username.text.toString(), password.text.toString())) {
            val intent = Intent(this, LoggedInActivity::class.java)
            startActivity(intent)
            finish()
        }
    }
}
Related