Я хочу открыть alertDialog, когда countDownTimer входит в onFini sh ()
Это мой CountDownTimer:
public void reverseTimer(int Seconds, final TextView tv) {
new CountDownTimer(Seconds * 1000 + 1000, 1000) {
@SuppressLint({"DefaultLocale", "SetTextI18n"})
public void onTick(long millisUntilFinished) {
int seconds = (int) (millisUntilFinished / 1000);
int minutes = seconds / 60;
seconds = seconds % 60;
tv.setText(String.format("%02d", minutes)
+ ":" + String.format("%02d", seconds));
}
@RequiresApi(api = Build.VERSION_CODES.M)
public final void onFinish() {
ShowDialog.show_dialog_fine_singoloGiocatore(activity_singolo_giocatore.this, bianco_nero, colore);
}
}.start();
}
И это функция для открытия AlertDialog:
public static void show_dialog_fine_singoloGiocatore(final Context c,final int black_white,final int color) {
AlertDialog.Builder builder = new AlertDialog.Builder(c);
FrameLayout frameView = new FrameLayout(c);
builder.setView(frameView);
AlertDialog alertDialog = builder.create();
LayoutInflater inflater = alertDialog.getLayoutInflater();
alertDialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
alertDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
View dialoglayout = inflater.inflate(R.layout.dialog_info, frameView);
TableLayout tableLayout = dialoglayout.findViewById(R.id.tableLayout);
alertDialog.show();
}
код генерирует эту ошибку:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.ApplicationInfo android.content.Context.getApplicationInfo()' on a null object reference"