今日のメモ

リファクタリングちう。気づきを以下に。

  • ロケーションが変わったら emulator から外部への通信ができない件
    • 一度 emulator オトさないと駄目な模様
    • 昨晩も職場から自宅に戻って試験したら UnknownHostException 吐いた件
  • emulator 起動し直したら_emulator: ERROR: the cache image is used by another emulator. aborting_なエラーがナニ
    • 再度 emulator 終了してみる
    • OSX 自体の挙動が微妙な可能性もあるだけに微妙orz
    • 動いた

テキストフィールドへの出力

res/layout/main.xml が以下だった。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

TextView の定義を以下に変更。

<TextView
    android:id="@+id/text1"  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />

これで R.id.text1 で findViewById でプログラム内で捕捉可能。以下なカンジ。

        TextView tmp = (TextView)findViewById(R.id.text1);
        tmp.setText("hello world");

ただ、よく考えてみるに GAE と認証のやりとりをして JSON 文字列なレスポンスが戻ってきてるだけなので、それをなんとかする必要あり。あと文字列なマジックナンバーが存在するので何とかする方向。

よく考えたら戻ってきてる JSON な文字列の処理を完全スルーしてるな。今はこんなカンジになってるので

        	String authKey = getAuthKey();
        	HttpResponse response = getAppspotContent(authKey, "/");

戻ってきた response で

  • JSON 文字列を生成
  • JSON オブジェクト生成

という手順で良いのか。

とは言え

今日の日中はこれで打ち止めとなります。mtg 漬け。

追記

忘れそうなので。
現状、上記な形にて

  • getAuthKey() は Google 認証して authKey な文字列を戻す
    • 認証 ID とパスワードを preference 方面で管理する方向ですが未実装
  • getAppspotContent() はある GAE アプリにアクセスしてレスポンスを戻すナニ
    • アプリの URL も可変にできる形の方が良さげ
    • このあたり別なクラスにした方が良さげ
    • ちなみに URI は可変な形になっております (引数で渡している