Database is saved on click but not going to the next class when clicked

Multi tool use
Database is saved on click but not going to the next class when clicked
public class JobSignup extends AppCompatActivity {
private Button btn;
private ImageView imageview;
private static final String IMAGE_DIRECTORY = "/demonuts";
private int GALLERY = 1, CAMERA = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_job_signup);
FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference myRef = database.getReferenceFromUrl("https://rozgarinepal100.firebaseio.com/");
final TextView userName = (TextView) findViewById(R.id.userName);
final EditText writeName = (EditText) findViewById(R.id.writeName);
ImageButton sendDataToFirebase = (ImageButton) findViewById(R.id.sendDataToFirebase);
final TextView dateOfBirth = (TextView) findViewById(R.id.dateOfBirth);
final EditText enterDateOfBirth = (EditText) findViewById(R.id.enterDateOfBirth);
if ( writeName.getText().toString().length() == 0)
{
writeName.setError("Username Compulsory");
}
// if( TextUtils.isEmpty(writeName.getText())) {
// /**
// * You can Toast a message here that the Username is Empty
// **/
//
// writeName.setError("First name is required!");
//
// }
sendDataToFirebase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myRef.child("0").child(userName.getText().toString()).setValue(writeName.getText().toString());
//myRef.child("NAME:").setValue("Kathmandu University");
myRef.child("0").child(dateOfBirth.getText().toString()).setValue(enterDateOfBirth.getText().toString());
}
});
}
public void onClick(View v) {
Intent i = new Intent(this, HomeActivity.class);
startActivity(i);
}
}
My code is running fine and database is also saved on click but on click it is not going to the next class using intent.Here in the onclick listener function i have added link for database when the button is clicked on android.Database is running fine on click operation but i am not able to go the next class which i have created.I have the only problem to go the next class when the same button is clicked.I am trying to enable the database and goto the next class using same button.
android:onClick="onClick"
Yes i have added that earlier.@NileshRathod
– Akash
Jul 3 at 5:25
did you get any error
– Nilesh Rathod
Jul 3 at 5:29
you are not adding your Intent inside your sendDataToFirebase() method.
– Thunder
Jul 3 at 6:37
1 Answer
1
Try this, It will work...
sendDataToFirebase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
myRef.child("0").child(userName.getText().toString()).setValue(writeName.getText().toString());
//myRef.child("NAME:").setValue("Kathmandu University");
myRef.child("0").child(dateOfBirth.getText().toString()).setValue(enterDateOfBirth.getText().toString());
Intent i = new Intent(JobSignup.this, HomeActivity.class);
startActivity(i);
}
});
Thanks a lot.It is working.
– Akash
Jul 3 at 5:30
Please think why It was not working before.Glad to help. Mark it as correct Answer
– Zaid Mirza
Jul 3 at 5:31
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
did you add
android:onClick="onClick"
in your view inside layout?– Nilesh Rathod
Jul 3 at 5:23