, пожалуйста, помогите мне с этой проблемой, мое приложение зависало, когда я пытаюсь запустить этот код. Я приложил скриншот моего logcat. Я реализовал исходный код по этой ссылке для счетчика кода страны https://github.com/joielechong/CountryCodePicker Я пытаюсьвыполнить действие, чтобы получить номер телефона пользователя и сохранить введенные пользователем данные в firebase Firestore
снимок экрана logcat
мой код активности java на андроид студии
import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.firestore.FirebaseFirestore;
import com.rilixtech.CountryCodePicker;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class introPage extends AppCompatActivity {
FirebaseAuth mAuth;
CountryCodePicker ccp;
EditText phoneNumber;
String countryName;
String phoneNum;
int countryCode;
FirebaseFirestore db;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ccp = (CountryCodePicker) findViewById(R.id.ccp);
phoneNumber = (EditText)findViewById(R.id.phoneNumberEditText);
phoneNum="";
countryCode = 0;
countryName="";
setContentView(R.layout.activity_intro_page);
if(mAuth == null) {
mAuth = FirebaseAuth.getInstance();
}
if(db == null) {
db = FirebaseFirestore.getInstance();
}
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setAdapter(new CustomPagerAdapter(this));
}
@Override
public void onBackPressed() {
//super.onBackPressed();
Toast.makeText(getApplicationContext(),"long press to sign out",Toast.LENGTH_SHORT).show();
}
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK)
{
mAuth.signOut();
startActivity(new Intent(introPage.this, LoginActivity.class));
finish();
return true;
}
return super.onKeyLongPress(keyCode, event);
}
public void getPhoneDetails(View view){
if(phoneNumber.getText().toString().length()==0){
Toast.makeText(getApplicationContext(),"Please key in phone number", Toast.LENGTH_SHORT).show();
}else{
FirebaseUser currentUser = mAuth.getCurrentUser();
String id = "";
id = currentUser.getUid().toString();
countryName = ccp.getSelectedCountryName();
countryCode = ccp.getSelectedCountryCodeAsInt();
phoneNum = phoneNumber.getText().toString();
Map<String, Object> infoUpdate = new HashMap<>();
infoUpdate.put("country", countryName);
infoUpdate.put("countryCode", countryCode);
infoUpdate.put("phoneNumber", phoneNum);
db.collection("users").document(id).update(infoUpdate)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Toast.makeText(getApplicationContext(), "Phone added", Toast.LENGTH_SHORT).show();
String storeData = "done intro";
try {
FileOutputStream fOut = openFileOutput("doneIntro",Context.MODE_PRIVATE);
fOut.write(storeData.getBytes());
fOut.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
startActivity(new Intent(introPage.this,barcodePage.class));
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(), "ERROR" + e.toString(), Toast.LENGTH_SHORT).show();
Log.d("TAG", e.toString());
}
});
}
}
}