I would suggest creating a dialog fragment instead. At that point you can handle the countdown timer in the fragment any which way you want.
Here's an example of a dialog fragment:
public class CountDownDialog extends DialogFragment {
private TextView mCountdownView;
public CountDownDialog(){}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_countdowntimer_dialog, container);
mCountdownView = (TextView) view.findViewById(R.id.countdownTimer);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
CountDownTimer gameTimer = new CountDownTimer(10000, 1000) {
@Override
public void onTick(long l) {
mCountdownView.setText(""+((int)Math.round(l/1000.0)-1));
}
@Override
public void onFinish() {
dismiss();
}
};
gameTimer.start();
}
}
and here's how you would call it
CountDownDialog countDownDialog = new CountDownDialog();
countDownDialog.show(getSupportFragmentManager(), "fragment_countdownTimer");
I used a pretty simple layout for the fragment to to test it:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Countdown:"
android:id="@+id/countdownTitle"
android:layout_marginLeft="@dimen/activity_horizontal_margin" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="9"
android:id="@+id/countdownTimer"
android:layout_marginLeft="8dp" />
</LinearLayout>