RecycleView
RecyclerView.Adapter<T extends BaseAdapter>
RecyclerView.ViewHolder<T extends BaseViewHolder>
LinearLayoutManager
RecycleView
RecyclerView.Adapter
RecyclerView.ViewHolder<T extends BaseViewHolder>
LinearLayoutManager
RecycleView
RecyclerView.Adapter
RecyclerView.ViewHolder
LinearLayoutManager
RecycleView
RecyclerView.Adapter<VH extends ViewHolder>
RecyclerView.ViewHolder
LinearLayoutManager
Intent(this, NextActivity::class.java).also { intent ->
startActivity(intent)
}
Intent(this, NextActivity::class.java).apply {
put(EXTRA_NEXT, "some data")
}.also { intent ->
activityStart(intent)
}
Intent(this, NextActivity::class.java).apply {
putExtra(EXTRA_NEXT, "some data")
}.also { intent ->
startActivity(intent)
}
Intent(this, NextActivity::class.java).apply {
put(EXTRA_NEXT, "some data")
}.also { intent ->
activityStart(intent)
}
in build.gradle:include ':app',':about' ':settings'
in settings.gradle:include ':app',':about' ':settings'
in settings.gradle:include ':about',':settings'
in gradle.properties:include ':app',':about' ':settings'
defaultConfig {
...
minApiVersion 21
targetApiVersion 28
}
defaultConfig {
...
targetSdkVersion 21
testSdkVersion 28
}
defaultConfig {
...
minSdkVersion 21
testApiVersion 28
}
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
}
private lateinit var textView: TextView
override fun onCreateView(...): View? {
val root = inflator.inflator(R>layout.fragment_home, container, false)
textView = ??
return root
}
Notice: AndroidJUnitRunner lets us run JUnit3/4-style tests on Android Devices
Explanation: In Method "getDefaultSharedPrefarances(this).getString()" Second parameter is passed so that it can be returned, in case key doesn't exist. So we need to pass an empty string to be returned in case key doesn't exist.
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="4dp"
android:color="@android:color/white" />
<solid android:color="@android:color/black" />
</shape>
<oval xmlns:android="http://schemas.android.com/apk/res/android">
<stroke android:width="4dp" android:color="@android:color/black"/>
<solid android:color="@android:color/white"/>
</oval>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="4dp"
android:color="@android:color/black" />
<solid android:color="@android:color/white" />
</shape>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="4dp"
android:color="@android:color/white" />
<solid android:color="@android:color/white" />
</shape>
<merge/>
<include/>
<layout/>
<add/>
android.permission.ACCESS_NETWORK_STATE
LinearLayout
? <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="center">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
val dialerIntent = Intent()
val et = findViewById(R.id.some_edit_text)
dialerIntent.action = Intent.ACTION_DIAL
dialerIntent.data = Uri.parse("tel:" + et.getText()?.toString())
startActivity(dialerIntent)
startActivityWithResult()
should be used instead of startActivity()
when using Intent.ACTION_DIAL
.Intent.ACTION_DIAL
, the Intent
option Intent.FLAG_ACTIVITY_NEW_TASK
must be added when using this dialerIntent
.dialerIntent
will cause an ActivityNotFoundException to be thrown on devices that do not support Intent.ACTION_DIAL
.android.permission.CALL_PHONE
must be requested first before Intent.ACTION_DIAL
can be used./assets
directory?resource ID
, like R.assets.filename
Resources.openRawResource()
intent
, instead of requesting the camera permission directly?intent
will respect your design choices.intent
will provide the UI.ActivityCompat.shouldShowRequestPermissionRationale()
function?release
builds. How can you create a new field in the generated BuildConfig
class to store that value?buildTypes {
debug {
buildConfig 'boolean', 'ENABLE_ANALYTICS', 'false'
}
release {
buildConfig 'boolean', 'ENABLE_ANALYTICS', 'true'
}
}
buildTypes {
debug {
buildConfig 'String', 'ENABLE_ANALYTICS', 'false'
}
release {
buildConfig 'String', 'ENABLE_ANALYTICS', 'true'
}
}
buildTypes {
debug {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'false'
}
release {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'true'
}
}
buildTypes {
debug {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'true'
}
release {
buildConfigField 'boolean', 'ENABLE_ANALYTICS', 'false'
}
}
ProGuard
-keepclassmembers have been added to the network data transfer objects (DTOs) in question@SerizlizedName
applied to its member properties <androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:padding="8dp"
android:textAlignment="center"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:textAlignment="center"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:padding="8dp"
android:textAlignment="center"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
...>
<TextView
android:id="@+id/text_dashboard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="8dp"
android:padding="8dp"
android:text="Dashboard"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
_not_
available to you by default when Android Studio creates a new project?Activity
class via an intent
? <activity android:name=".ExampleActivity" />
<activity android:name=".ExampleActivity">
<intent-filter>
<action android:name="android.intent.action.SEND" />
</intent-filter>
</activity>
<activity android:name=".ExampleActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".ExampleActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
Explanation: Intent filters are used to make activities accessible to other apps using intents. So we have to choose option which have no intent filter to make sure it is not accessible by intent
ActivityManager.isLowRamDevice()
method to find out whether a device defines itself as “low RAM.”Activity.islowRam()
method to find out whether a device defines itself as “low RAM.”ConnectivityManager.hasLowMemory()
method to find out whether a device defines itself as “low RAM.”_not_
a good way to reuse Android code?<include/>
to include them in other layout XML files. <shape xmlns:android-"http://schemas.android.com/apk/res/android"
android:shape-"oval">
<gradient
android:startColor-"@android:color/white"
android:endColor-"@android:color/black"
android:angle-"45"/>
</shape>
<rectangle xmlns:android-"http://schemas.android.com/apk/res/android">
<gradient
android:startColor-"@android:color/white"
android:endColor-"android:color/black"
android:angle-"135"/>
</rectangle>
<shape xmlns:android-"http://schemas.android.com/apk/res/android"
android:shape-"rectangle">
<gradient
android:startColor-"@android:color/white"
android:endColor-"@android:color/black"
android:angle-"135"/>
</shape>
<shape xmlns:android-"http://schemas.android.com/apk/res/android"
android:shape-"rectangle">
<gradient
android:startColor-"@android:color/white"
android:endColor-"@android:color/black"
android:angle-"98"/>
</shape>
android {
...
defaultConfig{...}
buildTypes{
debug{...}
releasae{...}
}
flavorDimensions "environment"
productFlavors {
producation {...}
staging {...}
}
}
Conversion to Dalvik format filed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
<?xml version=1.0 encoding="utf-8"?>
<resources>
<dimen name="spacing_medium">8dp</dimen>
<dimen name="spacing_large">12dp</dimen>
</resources>
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
android:src=@drawable/map_pin />
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
androi:layout_botttom="@dimen/spacing_medium"
android:src=@drawable/map_pin />
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
android:layout_marginBottom="@resources/spacing_medium"
android:src=@drawable/map_pin />
<ImageView
android:id=@+id/image_map_pin"
android:layout_width="wrap_content"
android:layout_heignt="wrap_content"
android:layout_marginBottom="@dimen/spacing_medium"
android:src=@drawable/map_pin />
override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_post_create)
if (savedInstanceState != null) return
val fragment = CreatePostFragment()
supportFragmentManager
.beginTransaction()
.add(R.id. fragment_container, fragment)
.commit()
}
Intent(this, AboutActivity::class).also { intent -> startService(intent)}
Intent(this, AboutActivity::class.java).also { intent -> startActivity(intent)}
Intent(this, AboutActivity::class).also { intent -> activity(intent)}
Intent(this, AboutActivity::class).also { intent -> startActivity(intent)}
Explanation: Intent(Context packageContext, Class<?> cls) Notice: Class not KClass
Explanation: When you build your project using Android Gradle plugin 3.4.0 or higher, the plugin no longer uses ProGuard to perform compile-time code optimization. Instead, the plugin works with the R8 compiler to handle
A
B
C
D
BuildConfig
BuildInfo
ConfigParams
ConfigInfo
<androidx.constraintlayout.widget.ConstrantLayout
...>
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstrantLayout>
The button does not have a size
The button is not constrained to the end of the parent container
Buttons cannot expand beyond their default size
The button should have its height set to 0dp as well
managing system services
processing user input events
loading data from the internet or a local data source
perfoming bitmap transformatinos
String
Text
String-array
Plurals
onPause()
onResume()
onOpen()
onStart()
fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
if (ContextCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.CAMERA) {
showCameraPreview()
}
else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
}
fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
showCameraPreview()
}
else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
}
fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
showCameraPreview()
}
fun showCamera(view: View) {
Log.i(TAG, "Show camera button pressed.")
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
showCameraPreview()
}
else {
requestPermissionLauncher.launch(Manifest.permission.CAMERA)
}
}