Android で 定数 (int)で enum を使うことは 

こんな記事を見かけた.

Why don't you use enum ? // Speaker Deck

...
public class Status {
  public static final int OK = 0;
  public static final int ERROR = 1;
}

public void onSomethingAction(int status) {
  switch (status) {
    case Status.OK:
      Log.d(TAG, “Status : OK”);
      break;
    case Status.ERROR:
      Log.d(TAG, “Status : NG”);
      break;
  }
}
...

より,

...
public enum Status {
  OK,
  ERROR
}

public void onSomethingAction(Status status) {
  Log.d(TAG, “Status : “ + status.name());
}
...

のほうがいいよね, と.

なんとなくここら「enum」についての議論を
よく見かけたような気がしたのですこし調べてみる.

even in the most recent documents android suggests that it's not such a good idea to use enums in an android application. The reason why is because they use up more memory than a static constants variable.

Working with Enums in android - Stack Overflow

Enums often require more than twice as much memory as static constants. You should strictly avoid using enums on Android.

java - Why Android uses Ints instead of Enums - Stack Overflow

Android_Memories____Speaker_Deck

Android Memories // Speaker Deck

公式ドキュメントには,

Be aware of memory overhead

Enums often require more than twice as much memory as static constants. You should strictly avoid using enums on Android.

Managing Your App's Memory | Android Developers

と書いてる.

他に,

Java enums are tremendously more expensive in code size than simple static final ints; classes and objects have not-insignificant overhead, so if you take a very class-heavy approach to your implementation you can end up with a significantly larger code size and RAM footprint for your app.

I really like this article on the importance of thinking about performance…

これに対して Jake Wharton さんも言及.

他には,

Should I strictly avoid using enums on Android?
No. Strictly means they are so bad, they should not be used at all. Possibly a performance issues might arise in an extreme situation like many many many (thousands or millions of) operations with enums (consecutive on the ui thread). Far more common are the network I/O operations that should strictly happen in a background thread. The most common usage of enums is probably some kind of type check - whether an object is this or that which is so fast you won't be able to notice a difference between a single comparison of enums and a comparison of integers.

java - Should I strictly avoid using enums on Android? - Stack Overflow

the original version of that document was just a bunch of prejudices. it's been rewritten to only contain facts backed up by actual benchmarks, and it's updated as the VM is updated. you can find the various benchmarks

Why was "Avoid Enums Where You Only Need Ints" removed from Android's performance tips? - Stack Overflow

結局,

オーバーヘッドは上がるが, まず最初はいうほど気にしなくてもよくね? 最近は. 見通しも良いし. 便利だし.

てな雰囲気でいいのかな. しらんけど.


もううんざりな「流行りの脆弱性」があるのか確認しながら

Androidの記事を眺めていると

海外のエントリソースに群がって

国内各メディアがさらに書き立てて

さらに私らがそれに群がり書きなぐる.

てな雰囲気でいつもAndroidと仲良しな「脆弱性」.

最近の2つについて,

チェックできるアプリがあるのでやってみました.

最近、セキュリティ研究者によってAndroid内蔵のメディアプレーヤー、Stagefrightに関わる一連の深刻な脆弱性が検出され、世界中のほぼすべてのAndroid端末が影響を受けることが明らかになりました。このStagefrightの脆弱性が攻撃者によって悪用されると、被害者にエクスプロイトを仕込んだマルチメディアメッセージ(MMS)を送信し遠隔操作によって端末からデータを搾取されるという深刻なセキュリティ問題が生じる恐れがあります。

Androidユーザー必読:Androidで新たな脆弱性「Stagefright 」を検出 | LOOKOUT ブログ

Stagefright Detector - Google Play の Android アプリ

20150810-143114

「Stagefright」はメディアプレイヤーフレームワークにまつわる脆弱性でしたが、Check Pointが報告した「Certifi-gate」は端末メーカーやネットワークサービスプロバイダーが用いるモバイル遠隔サポートツール(mRST)に関する脆弱性です。

mRSTは、サードパーティによるシステムレベルのプラグインと組み合わせることによって、端末の画面は現在どうなっているのかを把握したり、対象端末を遠隔で操作したりすることができるツールで、ユーザーから問い合わせを受けたときに、サポート担当者が遠隔で端末を操作することにより問題を解消するためのものです。しかし、mRSTには文字入力やアプリのインストールなどの特権があるので、悪用されるとユーザーの個人情報を盗まれたり、本来は端末の利用者でなければできない操作を行われる恐れがあります。

数百万台のAndroid端末が被害を受けうる脆弱性「Certifi-gate」の存在が明らかに - GIGAZINE

Certifi-gate Scanner - Google Play の Android アプリ

20150810-143045

と, あたしの場合は, 大丈夫なようですが,

多分, 今回のこの2つの脆弱性は,

大丈夫でなく晒されっぱなしの状態の端末も

今現在, 結構あるのだろうと思います.

正直, これらチェックアプリの判定で

「脆弱性あります!! 危険です!!」

といわれても, もう何もしない人のほうが多いような気がします.

そんなことはないか, 注意はしてるよな 注意は.


Android Studio のショーットカットが覚えられないので「CheatSheet」

こんな便利なショートカットあるのかと.

最近一番使っている道具であるAndroid Studioを見直してみました。
その結果、新たな便利機能を知ったり、改めて便利さを認識できたりしたので、メモがてら少しまとめてみました。

AndroidStudio - 普段使っている道具を見直す〜Android Studio編〜 - Qiita

眺めていると, 便利なのが多すぎて嫌になってきたのですが,

せっかくなので2,3個くらい覚えようと.

Override メソッドの一覧選択表示
ctrl + o

メソッド引数の種類表示
command + p

classの階層を表示
ctrl + h

...

多い. 多すぎる.

ショートカットが覚えられない

記事の最後に, こんな.

CheatSheet が便利です。
commandを長押ししているだけで、使用しているソフトウェアのCheatSheetが表示されます。

これを入れておくことにします.

CheatSheet

CheatSheet

インストールして, アクセサビリティまわりの許可をすると,

cheat

Screenshot_8_10_15__06_16

表示されます.

45438522-e948-9874-6714-5052a5563ca8

これって, Mac上どのアプリでもいけるのですね.便利だわ.

Android Studio の 設定検索のショートカット

Ctl + Shift + A

SlidingTabStrip

と合わせて使えば便利です.