为什么Android Studio无法检测到错误,但是当我尝试在移动设备上打开应用程序时却无法打开。
仅当我在“活动”中注释了这两行时,它才会打开,但是我当然没有获得全部功能。我想念什么吗?
注释行
\r?\n[([].+[)\]](?:\r?\n(?![\[\]()]).*)*\r?\n[\{(].+\r?\n
* Activity.java
spinner.findViewById(R.id.spinnerCountries);
spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,CountryData.countryNames));
这是我要连接到活动的文件
CountryData.java
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import com.google.firebase.FirebaseException;
import com.google.firebase.auth.FirebaseAuth;
public class RegisterActivity extends AppCompatActivity {
private Spinner spinner;
private EditText editText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
spinner.findViewById(R.id.spinnerCountries);
spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item,CountryData.countryNames));
editText = findViewById(R.id.editTextPhone);
findViewById(R.id.buttonContinue).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String code = CountryData.countryAreaCodes[spinner.getSelectedItemPosition()];
String number = editText.getText().toString().trim();
if (number.isEmpty() || number.length() < 10){
editText.setError("Valid number is required");
editText.requestFocus();
return;
}
String phonenumber = "+" + code + number;
Intent intent = new Intent (RegisterActivity.this,OtpActivity.class);
intent.putExtra("phonenumber",phonenumber);
startActivity(intent);
}
});
}
@Override
protected void onStart() {
super.onStart();
if (FirebaseAuth.getInstance().getCurrentUser() !=null) {
Intent intent = new Intent (this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
}
}