Kommunikation Version 1.5 UDP Socket
This commit is contained in:
parent
a85fb1f5ca
commit
ab54b6d96a
@ -18,7 +18,11 @@ import androidx.core.content.ContextCompat;
|
|||||||
public class PermissionRequest extends AppCompatActivity{
|
public class PermissionRequest extends AppCompatActivity{
|
||||||
private static final int PERMISSION_REQUEST_CODE = 123;
|
private static final int PERMISSION_REQUEST_CODE = 123;
|
||||||
private final MainActivity mainActivity;
|
private final MainActivity mainActivity;
|
||||||
|
|
||||||
|
boolean prüfen= false;
|
||||||
|
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
|
|
||||||
public PermissionRequest(MainActivity mainActivity) {
|
public PermissionRequest(MainActivity mainActivity) {
|
||||||
this.mainActivity = mainActivity;
|
this.mainActivity = mainActivity;
|
||||||
}
|
}
|
||||||
@ -47,73 +51,4 @@ public class PermissionRequest extends AppCompatActivity{
|
|||||||
public void rechteAnfordern() {
|
public void rechteAnfordern() {
|
||||||
mainActivity.requestPermissions(new String[]{CAMERA, RECORD_AUDIO, INTERNET}, PERMISSION_REQUEST_CODE);
|
mainActivity.requestPermissions(new String[]{CAMERA, RECORD_AUDIO, INTERNET}, PERMISSION_REQUEST_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
|
||||||
if (requestCode == PERMISSION_REQUEST_CODE && grantResults.length > 0) {
|
|
||||||
boolean rechtKamera = grantResults[0] == PackageManager.PERMISSION_GRANTED;
|
|
||||||
boolean rechtMikrofon = grantResults[1] == PackageManager.PERMISSION_GRANTED;
|
|
||||||
boolean rechtInternet = grantResults[2] == PackageManager.PERMISSION_GRANTED;
|
|
||||||
|
|
||||||
if (rechtKamera && rechtMikrofon && rechtInternet) {
|
|
||||||
handler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(mainActivity.getApplicationContext(), "Alle benötigten Rechte sind gewährt.", Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
mainActivity.runOnUiThread(() -> mainActivity.tvMessages.setText("Alle benötigten Rechte sind gewährt"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (!rechtKamera) {
|
|
||||||
handler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(mainActivity.getApplicationContext(),"Kein Recht auf Kamera gewährt.", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (shouldShowRequestPermissionRationale(CAMERA)) {
|
|
||||||
zeigeDialog("Du musst uns Zugriff auf deine Kamera gestatten, damit wir dich besser sehen können.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!rechtMikrofon) {
|
|
||||||
handler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(mainActivity.getApplicationContext(),"Kein Recht auf Mikrofon gewährt.", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (shouldShowRequestPermissionRationale(RECORD_AUDIO)) {
|
|
||||||
zeigeDialog("Du musst uns Zugriff auf dein Mikrofon gestatten, damit wir dich besser hören können.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!rechtInternet) {
|
|
||||||
handler.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Toast.makeText(mainActivity.getApplicationContext(),"Kein Recht auf Ortung gewährt.", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (shouldShowRequestPermissionRationale(INTERNET)) {
|
|
||||||
zeigeDialog("Du musst uns Zugriff auf dein Internet gestatten, damit wir eine Verbindung aufbauen können.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void zeigeDialog(String begruendung) {
|
|
||||||
new AlertDialog.Builder(mainActivity.getApplicationContext())
|
|
||||||
.setMessage(begruendung)
|
|
||||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
requestPermissions(new String[]{CAMERA, RECORD_AUDIO, INTERNET}, PERMISSION_REQUEST_CODE);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton("Abbruch", null)
|
|
||||||
.create()
|
|
||||||
.show();
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user