Hier mal die map.class
1public class map extends Activity implements OnClickListener {
2
3 private ImageButton buro;
4 private ImageButton rothenbach;
5 private ImageButton johannis;
6 private ImageButton sudstadt;
7 private ImageButton gartenstadt;
8
9
10 @Override
11 protected void onCreate(Bundle savedInstanceState) {
12 super.onCreate(savedInstanceState);
13 setContentView(R.layout.map);
14
15 final Activity teacherActivity = this;
16 teacherActivity.setTitle(R.string.titelmap);
17
18 buro = (ImageButton) findViewById(R.id.buttonbuero);
19 buro.setOnClickListener(this);
20
21 rothenbach= (ImageButton) findViewById(R.id.buttonroethenbach);
22 rothenbach.setOnClickListener(this);
23
24 johannis = (ImageButton) findViewById(R.id.buttonjohannis);
25 johannis.setOnClickListener(this);
26
27 sudstadt = (ImageButton) findViewById(R.id.buttonsudstadt);
28 sudstadt.setOnClickListener(this);
29
30 gartenstadt = (ImageButton) findViewById(R.id.buttongartenstadt);
31 gartenstadt.setOnClickListener(this);
32
33
34 }
35
36 @Override
37 public void onClick(View v)
38 {
39
40 Intent intent = new Intent();
41
42 switch (v.getId())
43 {
44
45 case R.id.buttonbuero:
46 intent.setClass(map.this, filialebuero.class);
47 startActivity(intent);
48 break;
49
50 case R.id.buttonroethenbach:
51 intent.setClass(map.this, filialeroethenbach.class);
52 startActivity(intent);
53 break;
54
55 case R.id.buttonjohannis:
56 intent.setClass(map.this, filialeschniegling.class);
57 startActivity(intent);
58 break;
59
60 case R.id.buttonsudstadt:
61 intent.setClass(map.this, filialesudstadt.class);
62 startActivity(intent);
63 break;
64
65 case R.id.buttongartenstadt:
66 intent.setClass(map.this, filialegartenstadt.class);
67 startActivity(intent);
68 break;
69
70
71 }
72
73 finish();
74 }
75
76}
welche dann auf z.B. die
1public class filialeschniegling extends map implements OnClickListener {
2
3 final Context context = this;
4 private Button phonebtn;
5
6 @Override
7 protected void onCreate(Bundle savedInstanceState) {
8 super.onCreate(savedInstanceState);
9 setContentView(R.layout.filialejohannis);
10
11 phonebtn = (Button) findViewById(R.id.callfilialeburo);
12
13 PhoneCallListener phoneCallListener = new PhoneCallListener();
14 TelephonyManager telManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
15 telManager.listen(phoneCallListener, PhoneStateListener.LISTEN_CALL_STATE);
16
17 phonebtn.setOnClickListener(new OnClickListener() {
18
19 @Override
20 public void onClick(View view) {
21
22 Intent phoneCallIntent = new Intent(Intent.ACTION_CALL);
23 phoneCallIntent.setData(Uri.parse("tel:123456789"));
24 startActivity(phoneCallIntent);
25
26 }
27 });
28
29
30 }
31
32 @Override
33 public void onClick(View v) {
34 finish();
35 }
36
37 private class PhoneCallListener extends PhoneStateListener {
38
39 String TAG = "LOGGING PHONE CALL";
40 private boolean phoneCalling = false;
41
42 @Override
43 public void onCallStateChanged(int state, String incomingNumber) {
44
45 if (TelephonyManager.CALL_STATE_RINGING == state) {
46
47 Log.i(TAG, "RINGING, number: " + incomingNumber);
48 }
49
50 if (TelephonyManager.CALL_STATE_OFFHOOK == state) {
51
52 Log.i(TAG, "OFFHOOK");
53
54 phoneCalling = true;
55 }
56
57 if (TelephonyManager.CALL_STATE_IDLE == state) {
58 Log.i(TAG, "IDLE");
59 if (phoneCalling) {
60 Log.i(TAG, "restart app");
61
62 Intent i = getBaseContext().getPackageManager()
63 .getLaunchIntentForPackage(
64 getBaseContext().getPackageName());
65
66 i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
67 startActivity(i);
68
69 phoneCalling = false;
70 }
71 }
72 }
73 }
74
75}
weiter geht.
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.