问题描述
我使用 Xamarin.Android 开发了 android 应用程序,它在 Android 8.1 - API27 模拟器上完美运行。当我尝试在 Newland MT9052 终端的真实设备上运行时,应用程序总是填写 FailureListener。
当我在调试模式下运行应用程序时,虽然电子邮件和密码正确,但应用程序填写到FailureListener。
这是我的 LoginActivity.cs:
TextInputLayout emailText;
TextInputLayout passwordText;
Button girisYapButton;
TextView txtViewUyeOl;
LinearLayout linearLayout;
FirebaseAuth mAuth;
TaskCompletionListener listener = new TaskCompletionListener();
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_login);
// Create your application here
emailText = (TextInputLayout)FindViewById(Resource.Id.textEmailLogin);
passwordText = (TextInputLayout)FindViewById(Resource.Id.textSifreLogin);
linearLayout = (LinearLayout)FindViewById(Resource.Id.linearLayout);
girisYapButton = (Button)FindViewById(Resource.Id.buttonGirisYap);
girisYapButton.Click += GirisYapButton_Click;
Initializefirebase();
txtViewUyeOl = (TextView)FindViewById(Resource.Id.textViewUyeOl);
txtViewUyeOl.Click += txtViewUyeOl_Click;
}
private void GirisYapButton_Click(object sender,EventArgs e)
{
string email,password;
email = emailText.EditText.Text;
password = passwordText.EditText.Text;
if (!email.Contains("@"))
{
new Android.Support.V7.App.AlertDialog.Builder(this)
.SetPositiveButton("Tamam",(sender,args) =>
{
})
.SetMessage("Lütfen geçerli bir e-mail adresi giriniz!")
.SetTitle("Uyarı")
.Show();
return;
}
else if(password.Length < 6)
{
new Android.Support.V7.App.AlertDialog.Builder(this)
.SetPositiveButton("Tamam",args) =>
{
})
.SetMessage("Lütfen en az 6 karakterli şifrenizi giriniz!")
.SetTitle("Uyarı")
.Show();
return;
}
else
{
listener.Success += Listener_Success;
listener.Failure += Listener_Failure;
mAuth.SignInWithEmailAndPassword(email,password)
.AddOnSuccessListener(this,listener)
.AddOnFailureListener(this,listener);
}
}
private void Listener_Failure(object sender,EventArgs e)
{
Snackbar.Make(linearLayout,"Email veya şifreniz yanlış!",Snackbar.LengthShort).Show();
}
private void Listener_Success(object sender,EventArgs e)
{
StartActivity(typeof(MainActivity));
}
void Initializefirebase()
{
var app = FirebaseApp.InitializeApp(this);
if (app == null)
{
var options = new FirebaSEOptions.Builder()
.SetApplicationId("konumbulapp-1fc67")
.SetApiKey("AIzaSyA5yRMMJ8ztcdWbIcmOxLyY6Xl_xkDxWzI")
.SetDatabaseUrl("https://konumbulapp-1fc67-default-rtdb.firebaseio.com")
.SetStorageBucket("konumbulapp-1fc67.appspot.com")
.Build();
app = FirebaseApp.InitializeApp(this,options);
mAuth = FirebaseAuth.Instance;
}
else
{
mAuth = FirebaseAuth.Instance;
}
}
这是我的 TaskCompletionListener.cs:
public class TaskCompletionListener : java.lang.Object,IOnSuccessListener,IOnFailureListener
{
public event EventHandler Success;
public event EventHandler Failure;
public void OnSuccess(java.lang.Object result)
{
Success.Invoke(this,new EventArgs());
}
public void OnFailure(java.lang.Exception e)
{
Failure.Invoke(this,new EventArgs());
}
}
This my Application properties
我不知道我做错了什么或错过了什么。
当我构建应用程序时,我没有收到错误。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)