C2DM 終了 GCMへの移行は10月までに

こんなの表示されてます. デベロッパーコンソール.

c2dm_gcm

C2DM のサポートがまもなく終了 Android Cloud to Device Messaging(C2DM)のサポートが完全に終了し、以降のサポートが提供されなくなることを 4 月に発表いたしました。C2DM は、次世代の C2DM である Google クラウド メッセージング(GCM)に代わります。C2DM を使用しているアプリの GCM への移行に十分な時間をかけられるよう、移行期限は 10 月まで延長されています。

ClientLogin for Google Cloud Messaging (GCM) has been shut down - Google グループ

該当するかどうかは, 「gcm.jar」 を利用しているかをみればよい.と.

C2DM をまだ使用しているアプリがある場合は、できる限り速やかに GCM に移行してください。2015 年 10 月までにアプリを最新の GCM ライブラリに移行しないと、C2DM プッシュ メッセージングが正常に機能しなくなります。C2DM を使用しているかどうかは、実装で gcm.jar ライブラリまたは GCM ヘルパー ライブラリを使用しているかで判断できます。

取得したトークンの文字列自体ははそのまま使えるのだろうと思います.

Cloud Messaging   |   Google Developers

変更の詳細手順は以下から.

Try Cloud Messaging for Android   |   Cloud Messaging   |   Google Developers


JSON の処理速度を4倍以上にアップできる「LoganSquare」

The fastest JSON parsing and serializing library available for Android. Based on Jackson's streaming API, LoganSquare is able to consistently outperform GSON and Jackson's Databind library by 400% or more1. By relying on compile-time annotation processing to generate code, you know that your JSON will parse and serialize faster than any other method available.

benchmarks

For the curious, the buildscript and apply plugin lines add the apt plugin, which is what allows us to do compile-time annotation processing. The first dependency is what tells Gradle to process your JSON annotations, and the second dependency is our tiny 19kb runtime library that interfaces with the generated code for you.

hvisser / android-apt — Bitbucket

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
    }
}
apply plugin: 'com.neenbedankt.android-apt'

dependencies {
    apt 'com.bluelinelabs:logansquare-compiler:1.1.0'
    compile 'com.bluelinelabs:logansquare:1.1.0'
}

bluelinelabs/LoganSquare


Android の タッチイベント とか

今や重なりあったアクション付きのUIが流行りとなり, 当然「タッチイベント」も重なり合ってくるわけでのメモ.

devsbuild_it_sites_default_files_PRE_andevcon_mastering-the-android-touch-system_pdf

andevcon_mastering-the-android-touch-system.pdf

「親から子(背面から前面)に伝わっていく」ので, activity → view.

Android のタッチイベントを理解する(その1) - Unmotivated

なので, 早めに捉えると範囲が広く, 遅めに捉えると限定的で実装手間も少なくできる.

Android: Difference between onInterceptTouchEvent and dispatchTouchEvent? - Stack Overflow

親で伝搬を止める.

...
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    boolean response = super.onInterceptTouchEvent(event);
    float x = event.getX();
    switch (event.getActionMasked()) {
    case MotionEvent.ACTION_DOWN:
        mTouchX = x;
        break;
    case MotionEvent.ACTION_MOVE:
        float dX = Math.abs(x - mTouchX);
        if (dX > minSwipeDistance)
            return true;
        break;
    }
    return response;
}
...

子から伝搬を止めるのをやめさせる.

...
findViewById(R.id.button)
    .getParent()
    .requestDisqllowInterceptTouchEvent(true);
...

ほとんどのユーザからのイベントは重なっていることを実感するなど.

Correctly detecting a swipe on a GridView placed inside a ViewPager in Android - Stack Overflow


コードを貼るだけ簡単で綺麗な「Share Button」

簡単で綺麗ですよ.

とりあえず貼っておけばいいですよね, こーゆーの.

Share_Button_-_give_your_website_more_social_traffic 2

Share_Button_-_give_your_website_more_social_traffic

スマホでもこんなかんじに表示されます.

20150118-141400

5行のコードを貼るだけです.

Share_Button_-_give_your_website_more_social_traffic 3

まずは貼って試してみよう!!

Share Button - give your website more social traffic


API-19 と 20+ 間を Material Design でどう跨いでいけばいいのか

Introduction_-_Material_design_-_Google_design_guidelines

とりあえず公式をみてみる.

* テーマの設定

1. Holoのようなこれまでのテーマを継承して定義する
res/values/style.xml

2. 同じ名前でテーマをMaterialテーマを継承して定義する.
res/values-v21/style.xml

3. これらのテーマを AndroidManifest.xmlでアプリに設定する.

* レイアウトの設定

21+向けのディレクトリをそれぞれ準備する
res/layout-v21/
res/values-v21/

API-21+ に対しては, 各リソースファイルを「*-v21」として新規に作成するという考え方.

これまでのUIデザインを変化させずに, 新しく OS 5.0+ の端末に対してのみマテリアルなデザインを表示させる.

その後にこう書いてる.

* サポートライブラリをセット

Theme.AppCompat を使えば いくつかのウィジェットは MaterialDesign のものを使える.

dependencies {
compile 'com.android.support:appcompat-v7:21.0.+'
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
}

EditText
Spinner
CheckBox
RadioButton
SwitchCompat
CheckedTextView
RecyclerView
CardView
Palette

完全ではないもののいくつかのウィジェットは appcompat-v7 で対応できる.

Lollipopを載せた端末の拡散具合や人気を考えると, OS4.x系端末でのマテリアルデザイン表示をしないと「マテリアルデザインに対応します(しました)」とうたいづらい.

よほどUIが凝ったアプリで無い限り, この appcompat-v7 ウィジェットを使って, これまで(API-19まで)のテーマに適用する, まずは.

/res/values/styles.xml

...
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...

とこれまでのテーマの親にもつ.

このあと, 微調整を行い, API-19までのUIをマテリアルなかんじに仕上げていき, そのあと *-v21 のリソースを触りながら, 気にせず Lollipop端末に向けてのマテリアル化を進めていく.

と, そんな順序が王道ではないかな...

Maintaining Compatibility | Android Developers