tmZdanie Flashcards

1
Q

Uprawnienia do odpalenia aparatu

A

3 wpisy w AndroidManifest.xml (do androiad 6.0):

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Sprawdzenie w kodzie czy ma się uprawnienie do kamery (kotlin)

A

ContextCompat.checkSelfPermission(
this,
Manifest.permission.CAMERA
) == PackageManager.PERMISSION_GRANTED -> {
// zrób coś, np wyświetl komunikat
Toast.makeText(getApplicationContext(), “Mam kamere!!!”, Toast.LENGTH_SHORT).show();
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Sprawdzenie czy ma się uprawnienie do kamery i jeśli tak wyświetlenie zdjęcia

A

if (getApplicationContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_CAMERA)) {
Toast.makeText(getApplicationContext(), “Mam kamere!!!”, Toast.LENGTH_SHORT).show();
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Proszenie o uprawnienia

A

when {
ContextCompat.checkSelfPermission(
CONTEXT,
Manifest.permission.REQUESTED_PERMISSION
) == PackageManager.PERMISSION_GRANTED -> {
// You can use the API that requires the permission.
}
shouldShowRequestPermissionRationale(…) -> {
// In an educational UI, explain to the user why your app requires this
// permission for a specific feature to behave as expected. In this UI,
// include a “cancel” or “no thanks” button that allows the user to
// continue using your app without granting the permission.
showInContextUI(…)
}
else -> {
// You can directly ask for the permission.
// The registered ActivityResultCallback gets the result of this request.
requestPermissionLauncher.launch(
Manifest.permission.REQUESTED_PERMISSION)
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Nadpisanie funkcji gdy poprawnie uzyskano poprawnienie

A
override fun onRequestPermissionsResult(requestCode: Int,
        permissions: Array, grantResults: IntArray) {
    when (requestCode) {
        PERMISSION_REQUEST_CODE -> {
            // If request is cancelled, the result arrays are empty.
            if ((grantResults.isNotEmpty() &&
                    grantResults[0] == PackageManager.PERMISSION_GRANTED)) {
                // Permission is granted. Continue the action or workflow
                // in your app.
            } else {
                // Explain to the user that the feature is unavailable because
                // the features requires a permission that the user has denied.
                // At the same time, respect the user's decision. Don't link to
                // system settings in an effort to convince the user to change
                // their decision.
            }
            return
        }
        // Add other 'when' lines to check for other
        // permissions this app might request.
        else -> {
            // Ignore all other requests.
        }
    }
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

jeżeli chcemy mieć pewność, że sterowanie do nas wróci to można wykorzystać

A

registerForActivityResult

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Kamera - uprawnienia

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Sprawdzanie czy ma się kamerkę

A

if (getApplicationContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_CAMERA)) {
Toast.makeText(getApplicationContext(), “Mam kamere!!!”, Toast.LENGTH_SHORT).show();
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Lokalizacja GPS - uprawnienia

A

ACCESS_FINE_LOCATION - dokładna
ACCESS_COARSE_LOCATION - nie aż tak dokładna
ACCESS_BACKGROUND_LOCATION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

WebView - do pliku xml

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Akcelerometr

A

val sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
val sensor: Sensor? = sensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Żyroskop

A

val sensorManager = getSystemService(Context.SENSOR_SERVICE) as SensorManager
val sensor: Sensor? = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Uprawnienia do sensorów w xml

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Mediaplayer odtwarzanie dźwięku

A

MediaPlayer odtwarzacz = MediaPlayer.create(getApplicationContext(), R.raw.av);
odtwarzacz.start();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Odtwarzanie dźwięku z internetu

A

String adres = “http://ingeb.org/refer/gaudeamu.MP3”; MediaPlayer odtwarzacz = new MediaPlayer(); odtwarzacz.setAudioStreamType( AudioManager.STREAM_MUSIC); odtwarzacz.setDataSource(adres); odtwarzacz.prepare(); odtwarzacz.start();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Obsługa ekranu przy wyświetlaniu multimediów

A

setDisplay()

setScreenOnWhilePlaying(Wł./Wył.)

17
Q

Obsługiwane formaty A/V

A

Audio: mp3, midi, wave, 3gp
Obraz: jpeg, gif, png, bmp
Video: mp4, 3gp