FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
I need your help as I getting errors as below and my new user registration not being added to Firebase.
- E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
- E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
- GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 11743470
- W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
I'm not sure if i missed anything in the coding.
public class MainActivity extends AppCompatActivity {
Button btnSignIn, btnSignUp;
RelativeLayout rootLayout;
FirebaseAuth auth;
FirebaseDatabase db;
DatabaseReference users;
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Arkhip_font.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
setContentView(R.layout.activity_main);
auth = FirebaseAuth.getInstance();
db = FirebaseDatabase.getInstance();
users = db.getReference("Users");
btnSignUp = (Button) findViewById(R.id.btnSignUp);
btnSignIn = (Button) findViewById(R.id.btnSignIn);
rootLayout = (RelativeLayout) findViewById(R.id.rootLayout) ;
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showRegisterDialog();
}
});
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showLoginDialog();
}
});
}
private void showLoginDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign In");
dialog.setMessage("Please use email to sign in");
LayoutInflater inflater = LayoutInflater.from(this);
View login_layout = inflater.inflate(R.layout.layout_login,null);
final MaterialEditText edtEmail = login_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = login_layout.findViewById(R.id.edtPassword);
dialog.setView(login_layout);
dialog.setPositiveButton("Sign In", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (TextUtils.isEmpty(edtEmail.getText().toString())) {
Snackbar.make(rootLayout, "Please enter email address", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (TextUtils.isEmpty(edtPassword.getText().toString())) {
Snackbar.make(rootLayout, "Please enter password", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (edtPassword.getText().toString().length() < 6) {
Snackbar.make(rootLayout, "Password too short!", Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.signInWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
startActivity(new Intent(MainActivity.this,Welcome.class));
finish();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
}
private void showRegisterDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign Up");
dialog.setMessage("Please use email to sign up");
LayoutInflater inflater = LayoutInflater.from(this);
View register_layout = inflater.inflate(R.layout.layout_signup,null);
final MaterialEditText edtEmail = register_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = register_layout.findViewById(R.id.edtPassword);
final MaterialEditText edtName = register_layout.findViewById(R.id.edtName);
final MaterialEditText edtNRIC = register_layout.findViewById(R.id.edtNRIC);
final MaterialEditText edtAddress = register_layout.findViewById(R.id.edtAddress);
final MaterialEditText edtMobile = register_layout.findViewById(R.id.edtMobile);
dialog.setView(register_layout);
dialog.setPositiveButton("Sign Up", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if(TextUtils.isEmpty(edtEmail.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter email address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtMobile.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter phone number",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtName.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter name",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtAddress.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtNRIC.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter 12 digits NRIC",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtPassword.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter password",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(edtPassword.getText().toString().length()<6)
{
Snackbar.make(rootLayout,"Password too short!",Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.createUserWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
User user = new User();
user.setEmail(edtEmail.getText().toString());
user.setPassword(edtPassword.getText().toString());
user.setName(edtName.getText().toString());
user.setNRIC(edtNRIC.getText().toString());
user.setAddress(edtAddress.getText().toString());
user.setMobile(edtMobile.getText().toString());
users.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Snackbar.make(rootLayout,"Sign up successfully!",Snackbar.LENGTH_SHORT)
.show();
return;
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
android-studio
add a comment |
I need your help as I getting errors as below and my new user registration not being added to Firebase.
- E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
- E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
- GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 11743470
- W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
I'm not sure if i missed anything in the coding.
public class MainActivity extends AppCompatActivity {
Button btnSignIn, btnSignUp;
RelativeLayout rootLayout;
FirebaseAuth auth;
FirebaseDatabase db;
DatabaseReference users;
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Arkhip_font.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
setContentView(R.layout.activity_main);
auth = FirebaseAuth.getInstance();
db = FirebaseDatabase.getInstance();
users = db.getReference("Users");
btnSignUp = (Button) findViewById(R.id.btnSignUp);
btnSignIn = (Button) findViewById(R.id.btnSignIn);
rootLayout = (RelativeLayout) findViewById(R.id.rootLayout) ;
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showRegisterDialog();
}
});
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showLoginDialog();
}
});
}
private void showLoginDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign In");
dialog.setMessage("Please use email to sign in");
LayoutInflater inflater = LayoutInflater.from(this);
View login_layout = inflater.inflate(R.layout.layout_login,null);
final MaterialEditText edtEmail = login_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = login_layout.findViewById(R.id.edtPassword);
dialog.setView(login_layout);
dialog.setPositiveButton("Sign In", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (TextUtils.isEmpty(edtEmail.getText().toString())) {
Snackbar.make(rootLayout, "Please enter email address", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (TextUtils.isEmpty(edtPassword.getText().toString())) {
Snackbar.make(rootLayout, "Please enter password", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (edtPassword.getText().toString().length() < 6) {
Snackbar.make(rootLayout, "Password too short!", Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.signInWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
startActivity(new Intent(MainActivity.this,Welcome.class));
finish();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
}
private void showRegisterDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign Up");
dialog.setMessage("Please use email to sign up");
LayoutInflater inflater = LayoutInflater.from(this);
View register_layout = inflater.inflate(R.layout.layout_signup,null);
final MaterialEditText edtEmail = register_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = register_layout.findViewById(R.id.edtPassword);
final MaterialEditText edtName = register_layout.findViewById(R.id.edtName);
final MaterialEditText edtNRIC = register_layout.findViewById(R.id.edtNRIC);
final MaterialEditText edtAddress = register_layout.findViewById(R.id.edtAddress);
final MaterialEditText edtMobile = register_layout.findViewById(R.id.edtMobile);
dialog.setView(register_layout);
dialog.setPositiveButton("Sign Up", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if(TextUtils.isEmpty(edtEmail.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter email address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtMobile.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter phone number",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtName.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter name",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtAddress.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtNRIC.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter 12 digits NRIC",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtPassword.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter password",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(edtPassword.getText().toString().length()<6)
{
Snackbar.make(rootLayout,"Password too short!",Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.createUserWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
User user = new User();
user.setEmail(edtEmail.getText().toString());
user.setPassword(edtPassword.getText().toString());
user.setName(edtName.getText().toString());
user.setNRIC(edtNRIC.getText().toString());
user.setAddress(edtAddress.getText().toString());
user.setMobile(edtMobile.getText().toString());
users.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Snackbar.make(rootLayout,"Sign up successfully!",Snackbar.LENGTH_SHORT)
.show();
return;
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
android-studio
add a comment |
I need your help as I getting errors as below and my new user registration not being added to Firebase.
- E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
- E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
- GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 11743470
- W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
I'm not sure if i missed anything in the coding.
public class MainActivity extends AppCompatActivity {
Button btnSignIn, btnSignUp;
RelativeLayout rootLayout;
FirebaseAuth auth;
FirebaseDatabase db;
DatabaseReference users;
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Arkhip_font.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
setContentView(R.layout.activity_main);
auth = FirebaseAuth.getInstance();
db = FirebaseDatabase.getInstance();
users = db.getReference("Users");
btnSignUp = (Button) findViewById(R.id.btnSignUp);
btnSignIn = (Button) findViewById(R.id.btnSignIn);
rootLayout = (RelativeLayout) findViewById(R.id.rootLayout) ;
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showRegisterDialog();
}
});
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showLoginDialog();
}
});
}
private void showLoginDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign In");
dialog.setMessage("Please use email to sign in");
LayoutInflater inflater = LayoutInflater.from(this);
View login_layout = inflater.inflate(R.layout.layout_login,null);
final MaterialEditText edtEmail = login_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = login_layout.findViewById(R.id.edtPassword);
dialog.setView(login_layout);
dialog.setPositiveButton("Sign In", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (TextUtils.isEmpty(edtEmail.getText().toString())) {
Snackbar.make(rootLayout, "Please enter email address", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (TextUtils.isEmpty(edtPassword.getText().toString())) {
Snackbar.make(rootLayout, "Please enter password", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (edtPassword.getText().toString().length() < 6) {
Snackbar.make(rootLayout, "Password too short!", Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.signInWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
startActivity(new Intent(MainActivity.this,Welcome.class));
finish();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
}
private void showRegisterDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign Up");
dialog.setMessage("Please use email to sign up");
LayoutInflater inflater = LayoutInflater.from(this);
View register_layout = inflater.inflate(R.layout.layout_signup,null);
final MaterialEditText edtEmail = register_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = register_layout.findViewById(R.id.edtPassword);
final MaterialEditText edtName = register_layout.findViewById(R.id.edtName);
final MaterialEditText edtNRIC = register_layout.findViewById(R.id.edtNRIC);
final MaterialEditText edtAddress = register_layout.findViewById(R.id.edtAddress);
final MaterialEditText edtMobile = register_layout.findViewById(R.id.edtMobile);
dialog.setView(register_layout);
dialog.setPositiveButton("Sign Up", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if(TextUtils.isEmpty(edtEmail.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter email address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtMobile.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter phone number",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtName.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter name",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtAddress.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtNRIC.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter 12 digits NRIC",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtPassword.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter password",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(edtPassword.getText().toString().length()<6)
{
Snackbar.make(rootLayout,"Password too short!",Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.createUserWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
User user = new User();
user.setEmail(edtEmail.getText().toString());
user.setPassword(edtPassword.getText().toString());
user.setName(edtName.getText().toString());
user.setNRIC(edtNRIC.getText().toString());
user.setAddress(edtAddress.getText().toString());
user.setMobile(edtMobile.getText().toString());
users.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Snackbar.make(rootLayout,"Sign up successfully!",Snackbar.LENGTH_SHORT)
.show();
return;
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
android-studio
I need your help as I getting errors as below and my new user registration not being added to Firebase.
- E/FirebaseInstanceId: Failed to resolve target intent service, skipping classname enforcement
- E/FirebaseInstanceId: Error while delivering the message: ServiceIntent not found.
- GooglePlayServicesUtil: Google Play services out of date. Requires 12451000 but found 11743470
- W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
I'm not sure if i missed anything in the coding.
public class MainActivity extends AppCompatActivity {
Button btnSignIn, btnSignUp;
RelativeLayout rootLayout;
FirebaseAuth auth;
FirebaseDatabase db;
DatabaseReference users;
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/Arkhip_font.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
setContentView(R.layout.activity_main);
auth = FirebaseAuth.getInstance();
db = FirebaseDatabase.getInstance();
users = db.getReference("Users");
btnSignUp = (Button) findViewById(R.id.btnSignUp);
btnSignIn = (Button) findViewById(R.id.btnSignIn);
rootLayout = (RelativeLayout) findViewById(R.id.rootLayout) ;
btnSignUp.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showRegisterDialog();
}
});
btnSignIn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showLoginDialog();
}
});
}
private void showLoginDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign In");
dialog.setMessage("Please use email to sign in");
LayoutInflater inflater = LayoutInflater.from(this);
View login_layout = inflater.inflate(R.layout.layout_login,null);
final MaterialEditText edtEmail = login_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = login_layout.findViewById(R.id.edtPassword);
dialog.setView(login_layout);
dialog.setPositiveButton("Sign In", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if (TextUtils.isEmpty(edtEmail.getText().toString())) {
Snackbar.make(rootLayout, "Please enter email address", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (TextUtils.isEmpty(edtPassword.getText().toString())) {
Snackbar.make(rootLayout, "Please enter password", Snackbar.LENGTH_SHORT)
.show();
return;
}
if (edtPassword.getText().toString().length() < 6) {
Snackbar.make(rootLayout, "Password too short!", Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.signInWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
startActivity(new Intent(MainActivity.this,Welcome.class));
finish();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Failed"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
}
private void showRegisterDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle("Sign Up");
dialog.setMessage("Please use email to sign up");
LayoutInflater inflater = LayoutInflater.from(this);
View register_layout = inflater.inflate(R.layout.layout_signup,null);
final MaterialEditText edtEmail = register_layout.findViewById(R.id.edtEmail);
final MaterialEditText edtPassword = register_layout.findViewById(R.id.edtPassword);
final MaterialEditText edtName = register_layout.findViewById(R.id.edtName);
final MaterialEditText edtNRIC = register_layout.findViewById(R.id.edtNRIC);
final MaterialEditText edtAddress = register_layout.findViewById(R.id.edtAddress);
final MaterialEditText edtMobile = register_layout.findViewById(R.id.edtMobile);
dialog.setView(register_layout);
dialog.setPositiveButton("Sign Up", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
if(TextUtils.isEmpty(edtEmail.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter email address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtMobile.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter phone number",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtName.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter name",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtAddress.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter address",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtNRIC.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter 12 digits NRIC",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(TextUtils.isEmpty(edtPassword.getText().toString()))
{
Snackbar.make(rootLayout,"Please enter password",Snackbar.LENGTH_SHORT)
.show();
return;
}
if(edtPassword.getText().toString().length()<6)
{
Snackbar.make(rootLayout,"Password too short!",Snackbar.LENGTH_SHORT)
.show();
return;
}
auth.createUserWithEmailAndPassword(edtEmail.getText().toString(),edtPassword.getText().toString())
.addOnSuccessListener(new OnSuccessListener<AuthResult>() {
@Override
public void onSuccess(AuthResult authResult) {
User user = new User();
user.setEmail(edtEmail.getText().toString());
user.setPassword(edtPassword.getText().toString());
user.setName(edtName.getText().toString());
user.setNRIC(edtNRIC.getText().toString());
user.setAddress(edtAddress.getText().toString());
user.setMobile(edtMobile.getText().toString());
users.child(FirebaseAuth.getInstance().getCurrentUser().getUid())
.setValue(user)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Snackbar.make(rootLayout,"Sign up successfully!",Snackbar.LENGTH_SHORT)
.show();
return;
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Snackbar.make(rootLayout,"Sign up failed!"+e.getMessage(),Snackbar.LENGTH_SHORT)
.show();
return;
}
});
}
});
dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
dialog.show();
android-studio
android-studio
asked Nov 23 at 8:30
Wong
11
11
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443064%2ffirebaseinstanceid-failed-to-resolve-target-intent-service-skipping-classname%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53443064%2ffirebaseinstanceid-failed-to-resolve-target-intent-service-skipping-classname%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown