2022-01-01から1年間の記事一覧

Android Study Jamに参加して先着50名のグッズを頂いた。

2022年7、8月にGoogle Japanが主催していたAndroid Study Jamに参加した。 Androidアプリの新しいUI開発ツールであるJetpack Composeを普及する施策である。 こういうのが主催されるってことは、まだ従来のAndroid Viewを使う人が多数派で、先ずJetpack Comp…

AndroidでParcelable、Serializable、Enumのクラスを使う時は@Keepも共に使おう

AndroidアプリではProGuardへの対応はまあ必須である。 圧縮プロセスの過程で、Parcelable、Serializable、Enum のクラス名が難読化されないようにする必要がある。その対応方法 @Keepアノテーションを使用する @Keep class ParcelableArg : Parcelable { ..…

Jetpack DataStoreを消去する

公式に良いのが見つからなかったのでメモ Preferences DataStore // 消去 context.dataStore.edit { it.clear() } // 定義 val Context.dataStore by preferencesDataStore(name = "settings") Proto DataStore // 消去 context.datastore.updateData { it.t…

KotlinのCharをIntにする

KotlinのCharを10進数のIntにするにはdigitToInt() digitToInt - Kotlin Programming Language Kotlinバージョンは1.5以上 println('5'.digitToInt()) // 5 println('3'.digitToInt(radix = 8)) // 3 println('A'.digitToInt(radix = 16)) // 10 println('k'…

ComposeViewでのテキストのautoLink対応

Text()にTextViewのandroid:autoLinkに相当するものがなかったので、実装 TextView | Android Developers @Composable fun DefaultLinkifyText( modifier: Modifier = Modifier, text: String?, textAppearance: Int = android.R.style.TextAppearance_Mater…

ListAdapterのサンプル実装

abstract class ListAdapter : RecyclerView.Adapter developer.android.com サンプル実装 data class Tweet( val text: String, val id: Long, ) class TweetAdapter( private val onClick: (Tweet) -> Unit ) : ListAdapter<Tweet, TweetAdapter.ItemViewHolder>(DIFF_UTIL_ITEM_CALLBACK) { cl</tweet,>…

error: Schema export directory is not provided to the annotation processor so we cannot export the schema.

Dagger Hilt を使っている時に遭遇。 Roomを使っているクラスを置き換えているとき、ビルドエラー発生。 メッセージ: Schema export directory is not provided to the annotation processor so we cannot export the schema. Databaseを定義する際のアノテ…

Kotlin Android Extensions pluginがKotlin 1.8で削除されるそうです

android-developers.googleblog.com Kotlin Android Extensions pluginはfindViewByIdを書くのを減らしたり、Parcelizeを使うために、使われてきました。 In November 2020, we announced that this plugin has been deprecated in favor of better solution…

なぜNavigation Component を使ったSingle Activity Architectureをお勧めするのか

表題について上手く言語化してある記事を見つけたので紹介したい。 oozou.com Since the announcement of Jetpack in Google I/O 2018, Single Activity Architecture is also mentioned Android Developers Blog: Use Android Jetpack to Accelerate Your A…

AndroidのButtonでアルファベットテキストが全て大文字になる

qiita.com 大文字小文字を区別したい時の解決策は、レイアウトxmlでandroid:textAllCaps="false"と指定してあげることです。 ボタンテキストは大文字固定がデフォルトになっているようです。 // example <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="hoge" android:textAllCaps="false" /> リファレンス developer.android.com</button>