gradle なら AndroidManifest.xml 内 <uses-sdk> が不要だった件

_uses-sdk____Android_Developers

Android Studio が警告なフキダシを出してる.

main_AndroidManifest

記述が2箇所あってきもちが悪かったのですが.

build.gradle

android {
    ...
    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }
    ...
}

AndroidManifest.xml

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="19"/>

Android Studio の設定で「バージョン」の記述してるとこありすぎね?

で, AndroidManifest.xml側の記述は不要らしい.

Gradle overrides the manifest values, and I prefer to update build.gradle file rather than manifest. And probably this is the right way using Gradle. Gradle supports product flavours which can be controled via IDE and those product flavors can change many things in our Manifest like package name, version code, version name, target SDK and many other. Then by one click in Android Studio You can change many properties and generate another apk.

You can left the manifest as it is and do all configuration in build.gradle. You can safely remove

<uses-sdk></uses-sdk>

from manifest as well as version codes.

Android studio: why are minSdkVersion and targetSdkVersion specified both in AndroidManifest.xml and build.gradle? - Stack Overflow

Gradle が自動埋め込んでくれるっぽい.

apk化後, バラしてみてみると確認できます.

android-apktool - A tool for reverse engineering Android apk files - Google Project Hosting


【Wearable / Material Design 満載】アプリ「Google I/O 2014」のソースコードが利用可能に

google_iosched 2

google_iosched

google/iosched

毎年ソースコード公開していますが, 勉強になります, これ.

どんな機能があるかを汎用的にまとめると

・ edit your personal schedule
・ Sync your schedule between all of your devices and website
・ View detailed Google+ profiles
・ +1 sessions right from the app
・ Participate in conversations on Google+
・ using the vector-based map
・ Get a reminder in your schedule are due to start
・ View information in the Developer Sandbox
・ Play live video streams
・ Beam from your NFC-enabled device to another using Android Beam
・ Scan on your NFC-enabled device
・ Send feedback from your phone/tablet, or from your Android Wear device

ビルド時の説明も細かくあります.

iosched_BUILDING_md_at_master_·_google_iosched

Building without Android Wear
If you do not wish to build the Android Wear component, you can remove or comment out the following line on android/build.gradle:

wearApp project(":Wearable")

Also, remove ':Wearable' from settings.gradle, leaving only ':android'.

iosched/BUILDING.md at master · google/iosched

確認する価値はあると思われます.

Google announced in a blog post that it has released the source code to the…
Google I/O 2014 App Source Code Now Available | Android Developers Blog


Tinder のような 横スワイプできるカードなUIライブラリ「AndTinder」

こんな人気記事あります.

2日で約3000語を暗記、スマフォ世代の英単語学習アプリ「mikan」はTinderライク - TechCrunch

mikanでは左右にスワイプすることで次々とカードをめくっていくようなUIを採用している。これは、去年あたりからアメリカの若者の間で流行している出会いアプリの「Tinder」が生み出し、多くのアプリが採用しているスマフォ・ネイティブといっていいUIだ。

「素早く振り分けができる」てことなのだろうが, Yes/No ボタンでも同じじゃね?

などと思いつつ, ライブラリを探す.

Swipeable-Cards/AndTinder at master · kikoso/Swipeable-Cards

20140730-133942

20140730-133956

20140730-134023

20140730-134040

使い方は簡単で,

レイアウト内に View コンテナとして埋め込んで,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical">

    <com.andtinder.view.CardContainer
        android:id="@+id/layoutview"
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>
</LinearLayout>

利用 Activity でカード内のテキストと画像を指定.
スワイプ処理の Listener もここで.

public class MainActivity extends Activity {

  private CardContainer mCardContainer;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.mainlayout);

    mCardContainer = (CardContainer) findViewById(R.id.layoutview);

    Resources r = getResources();

    SimpleCardStackAdapter adapter = new SimpleCardStackAdapter(this);

    adapter.add(new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title2", "Description goes here", r.getDrawable(R.drawable.picture2)));
    ...

    cardModel.setOnClickListener(new CardModel.OnClickListener() {
      @Override
      public void OnClickListener() {
        Log.i("Swipeable Cards","I am pressing the card");
      }
    });

    cardModel.setOnCardDimissedListener(new CardModel.OnCardDimissedListener() {
       @Override
       public void onLike() {
         Log.i("Swipeable Cards","I like the card");
       }

       @Override
       public void onDislike() {
         Log.i("Swipeable Cards","I dislike the card");
       }
    });

    adapter.add(cardModel);
    mCardContainer.setAdapter(adapter);
  }
}

このUI, 実際使ってみると, 気持ちよすぎてクセになるんだわー

Tinder