3行未満のAndroid Tips集

記事にするまでもない3行未満で書けるレベルのTipsとリンク集。 常識レベルのものも含む。

URLのパスの結合にはUri.withAppendedPathを使う

スラッシュの重複を省いてくれて便利。 http://developer.android.com/reference/android/net/Uri.html

DBのColumnsはandroid.provider.BaseColumnsを継承する

中に_IDってフィールドがあるからそれ使う。 http://developer.android.com/reference/android/provider/BaseColumns.html

StringBufferとStringBuilder

StringBuilderのほうが圧倒的に軽い。 でもスレッドセーフじゃないから複数のスレッドからは呼べない。

Integer.toHexString

数値を16進文字列にする場合、Formatterより速い。 0xf以下の値を渡すと1桁しか出力しないので注意。

Deep Linkの提供

App-indexing以外にもGoogle+とGoogleAdsから提供できる http://developer.android.com/distribute/engage/deep-linking.html

Playストアへのリンクの貼り方

details?id=以外もある。 http://developer.android.com/distribute/tools/promote/linking.html

Playストアへのリンクボタン生成ページ

ランディングページとかに貼るやつ。 http://developer.android.com/distribute/tools/promote/badges.html

スクリーンショットに端末画像の枠つける

Nexus端末じゃないとダメ。 http://developer.android.com/distribute/tools/promote/device-art.html

便利な新機能の探し方

Android Developersを「Compat」で検索する→左側のメニューで「Reference」を選択する。 元のクラスとの差分が含まれたXXXCompat系がいっぱい表示されるので片っ端から見る。 Compatに含まれるくらいなんだから便利な新機能にきまっている。 http://developer.android.com/reference/android/support/v13/app/FragmentCompat.html#q=Compat

よく使うシステムブロードキャストの一覧

AndroidDevelopersのIntent#Standard Broadcast Actionsに書いてある http://developer.android.com/reference/android/content/Intent.html