Android FirebaseAuth未链接。跳过初始化

时间:2017-05-03 04:49:21

标签: android firebase firebase-realtime-database firebase-authentication

这是代码。我正在尝试创建一个新的子节点并保存数据,但是没有在firebase树上创建节点。但代码运行成功。但是在更新了sdk后,它无法正常工作。

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post__feed);
    initialize();
    btn_post_feed.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            UploadData();
        }
    });
}

private void initialize() {
    edt_details = (EditText) findViewById(R.id.post_feed_description);
    spinner_category = (Spinner) findViewById(R.id.post_feed_spinner);
    seekBar = (SeekBar) findViewById(R.id.post_feed_number);
    btn_post_feed = (Button) findViewById(R.id.post_feed_btn_post);
    sharedPreferences = getSharedPreferences("MODE", Context.MODE_PRIVATE);
    phn = sharedPreferences.getString("mobno", "A");
    value = sharedPreferences.getInt("value", 0);
}

@Override
public void UploadData() {
    reference1 = FirebaseDatabase.getInstance().getReference().child("feeds");

    detailsFeeds = new DetailsFeeds();
    detailsFeeds.setCategory(category);
    detailsFeeds.setItemDonateName(quantity);
    detailsFeeds.setPhoneNo(phn);
    detailsFeeds.setItemDonateName(details);
    if (value == 1)
        detailsFeeds.setStatus(true);
    else
        detailsFeeds.setStatus(false);
    reference2 = reference1.child(phn + detailsFeeds.getPostNumber());
    detailsFeeds.increasePostnumber();
    detailsFeeds.setPostNumber(detailsFeeds.getPostNumber());
            reference2.setValue(detailsRegister, new DatabaseReference.CompletionListener() {
        @Override
        public void onComplete(DatabaseError databaseError, DatabaseReference databaseReference) {

            if (databaseError == null) {
                setResult(789);
                finish();
            } else {
                Toast.makeText(getApplicationContext(), "Failed", Toast.LENGTH_SHORT).show();
                setResult(786);
                finish();
            }

        }
    });

}

@Override
public void DownloadData() {

}

@Override
public void FetchFields() {
    spinner_category.setOnItemSelectedListener(new CustomItemSelectedListener());
    details = edt_details.getText().toString();
    quantity = String.valueOf(seekBar.getProgress());
}

@Override
public boolean CheckFields() {
    return false;
}

private class CustomItemSelectedListener implements AdapterView.OnItemSelectedListener {
    @Override
    public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
        category = adapterView.getItemAtPosition(i).toString();
    }

    @Override
    public void onNothingSelected(AdapterView<?> adapterView) {

    }
}

}

Gradle

0 个答案:

没有答案