Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Android Log-ing not working



  • i have java code.

    Log.e("mail: ",account.name); - message is not displayed

    package org.qtproject.example;

    import org.qtproject.qt5.android.QtNative;
    import org.qtproject.qt5.android.bindings.QtApplication;
    import org.qtproject.qt5.android.bindings.QtActivity;

    import android.accounts.Account;
    import android.accounts.AccountManager;
    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;
    import android.util.Patterns;
    import java.util.regex.Pattern;

    public class Android_info extends org.qtproject.qt5.android.bindings.QtActivity{

    static String mail;
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        Pattern emailPattern = Patterns.EMAIL_ADDRESS; // API level 8+
        Account[] accounts = AccountManager.get(this).getAccounts();
        for (Account account : accounts) {
            if (emailPattern.matcher(account.name).matches()) {
                mail = account.name;
                Log.e("mail: ",account.name);
            }
        }
    }
    
    public static String return_mail(){
        return mail;
    }
    

    }


Log in to reply