Before the arrival of the match_parent
I used a lot fill_parent
to define the total width of the view
. I didn't quite understand why the Android development team went on to substitute one for the other. What is the difference between the match_parent
and the fill_parent
? Why fill_parent
was he replaced by match_parent
?
viana's questions
Snapchat has a functionality that is to notify the user every time someone, any other user, takes a screenshot of their stories.
At first I thought about the possibility of checking if the user pressed Volume Down+ Power, but nothing guarantees that the screenshot will be saved, since there may not be enough memory to save. Also, I think that each device can change the way how to capture the screen, not to mention that there are other applications that facilitate this process.
Another way would be to check if there have been any changes to the Screenshots directory, using the class FileObserver
, but there is also no guarantee that this path will be the same on all devices.
How can I check if the user took a screenshot at the time of using the app?
In Kotlin you can create a class like this:
data class Dragon(private val nombre: String, val type: Int)
What is the main goal of the data class
in Kotlin? When should we use?
When creating a view
, we use @+id/fullname
to identify it.
For example:
<TextView
android:id = "@+id/tv_fullname"
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:text = "Fullname" />
What is the difference of using @id/tv_fullname
(without the +), instead of @+id/ tv_fullname
? Is it correct to use one or the other?
To return the package name with the class name in Java I have always used the getName()
. I noticed that apparently the method getCanonicalName()
returns the same thing.
See just an example customizing the method toString()
:
@Override
public String toString() {
return this.getClass().getName();
}
Isso would apparently be equivalent to:
@Override
public String toString() {
return this.getClass().getCanonicalName();
}
What is the actual difference between the getCanonicalName()
and methods getName()
?