1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
...
final Handler handler = new Handler();
final Intent intent2 = new Intent(this, doaaActivity.class);
task = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
Random r = new Random();
int doaparjour = 0 + r.nextInt(99);
String DoaaT = LireXml(doaparjour);
CreateNotification(DoaaT);
Toast.makeText(MainActivity.this, DoaaT, Toast.LENGTH_SHORT).show();
LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View popupView = layoutInflater.inflate(R.layout.popup, null);
TextView textPop = (TextView)popupView.findViewById(R.id.textPop);
textPop.setText(DoaaT);
final PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
@Override
public void onClick(View v) {
popupWindow.dismiss();
}});
popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
}
});
}};
if(timer != null){
timer.cancel();
timer.purge();
timer = null;
TextView T = (TextView) findViewById(R.id.text_Doaa_res);
T.setText(checkedTime);
}
timer = new Timer();
// icheckedTime == "1000"
timer.schedule(task, 0, Long.parseLong(checkedTime));
... |
Partager