-
Notifications
You must be signed in to change notification settings - Fork 0
/
Prinzip_GPS_Empfang_Ueberwachung.java
62 lines (50 loc) · 1.58 KB
/
Prinzip_GPS_Empfang_Ueberwachung.java
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
54
55
56
57
58
59
60
61
62
package ch.nicolassauter.gps_test_wennaus;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
TextView textView;
// 10 ist Starwert für den Timer in der if Abfrage
volatile int i = 10;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.textView);
}
public void onclick_button(View v) {
if (i == 10) {
textView.setText("100");
new Thread(new Runnable() {
@Override
public void run() {
i = 0;
timer();
}
}).start();
} else {
// Immer wieder Nullen das Schleife wieder von vorne beginnt 3 Sekunden abzuzählen.
i = 0;
}
}
public void timer() {
for (; i < 3; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Toast.makeText(this, "Fehler!! :(", Toast.LENGTH_SHORT).show();
}
}
textView.post(new Runnable() {
@Override
public void run() {
// Kein Empfang mehr ¨'- - -'
textView.setText("- - -");
// Wieder Startwert Setzen für Neustart in onclick_button
i = 10;
}
});
}
}