Pro Android with Kotlin


Download 5.42 Mb.
Pdf ko'rish
bet206/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   202   203   204   205   206   207   208   209   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile



261
© Peter Späth 2018 
P. Späth, Pro Android with Kotlin
https://doi.org/10.1007/978-1-4842-3820-2_10
Chapter
10
Development
This chapter covers issues closer to development matters, compared to the previous 
chapters. The topics we will be talking about here are less tightly coupled to specific Android 
OS APIs. It is more our concern here to find out how technical requirements can best be 
accomplished using Kotlin methodologies.
The chapter also has a section that covers transcribing Kotlin code to JavaScript code that 
can serve WebView widgets.
Writing Reusable Libraries in Kotlin
Most tutorials you will find on the Web are about activities, services, broadcast receivers
and content providers. These components are reusable in the sense that you can more or 
less easily extract them from a project and copy them to another project. The encapsulation 
in the Android OS has reached an elaborate stage, which makes this reuse possible. On a 
lower level, however, in some cases the libraries or APIs that are provided inside Android 
might not suit all your needs, so you might be tempted to develop such libraries yourself and 
then copy the sources from project to project wherever feasible.
Surely, such a copying on the source code level does not fit well into modern methodologies 
for reusable libraries; just think about maintenance and versioning issues that introduce a 
lot of boilerplate efforts. The best thing is to design such reusable libraries as dedicated 
development artifacts. They then can be easily reused from different projects.
In the following sections, we develop a rudimentary regular expression library, serving as a 
conceptual basis for your own library projects.
Starting a Library Module
Library projects are projects containing one or more modules. With Android Studio open, 
create a new project and make sure it has Kotlin support enabled. Then, inside the new 
project go to New ➤ New module and choose Android Library.



Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   202   203   204   205   206   207   208   209   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling