What exactly is “label” parameter in ClipData in Android?

后端 未结 3 1190
無奈伤痛
無奈伤痛 2020-12-30 18:34

According to the Android documentation, ClipData use \"label\" as a kind of representation to the copied data.

ClippedData is a complex type containin

3条回答
  •  悲哀的现实
    2020-12-30 18:43

    It seems like the "User-visible label for the clip data" description in the documentation should be interpreted as something you as a developer can set and then show to the user yourself and not as something that the Android system will show to the user.

    When looking at the Android source code the ClipDescription.getLabel() method seems to be unused before Android 5.0. In 5.0 RemoteInput, RemoteInputCompatJellybean and com.android.mail.compose.ComposeActivity stated using the method.

    If you look at the usage all these set a label that is not meant to be seen by the user but instead used to programatically identify the clip at a different place in the code.

    When looking at how ClipData.newPlainText() is used within Android, most of the time null is given as label, suggesting the label is not really used for anything.

    It is of course possible that some phone manufacturer or some other app developer takes the label and displays it to the user in some situation. But in general it should be safe to assume that the label of a clip will only be shown to the user in your app if you show it yourself.

提交回复
热议问题