2011年11月アーカイブ

今までWindows2台をPC切替機を使って使用していたのだが、
MACが一時的に1台増えたので、Windows1台とMAC1台を
PC切替機につなぎ、残りのWindows1台はリモートデスクトップで
操作することにしました。

リモートデスクトップで操作されるWindows機からキーボード、
マウス、ディスプレイを取り外し、起動しようとしたところ
うまく起動しませんでした。

どうやらキーボードが接続されていないと起動できない設定に
なっているようです。

BIOSの設定を変更すればキーボード無しで起動できるようなの
以下の手順で設定しました。

・マシン起動時に[DEL]キーを押してBIOSの設定画面を起動
(BIOS設定画面の起動方法はボードによって違うと思います。
ちらっと英語で表示されるメッセージを見るとわかります)

・Halt On という項目を探し、[All Errors But] を選択して、
Keyboard と Mouse をEnable に設定
(ここの設定もBIOSによって違うと思いますが、要はキーボードと
マウスのエラー以外のエラーの時にストップする、という設定にします。)

以上で設定は終わり、キーボードとマウスを抜いてもちゃんと起動でき、
リモートデスクトップで接続できるようになりました。


Android で notificationをカスタマイズしてプログレスバー(ぐるぐる回るやつ)を
入れたのだが、通知バーを表示させてからフリックして通知バーを隠し、
再度表示させるとプログレスバーのアニメーションが止まっていた。

縦横を切り替えてやると動いたりして、よくわからない動き。

いろいろと調べたが美しい解決策は見つけられず、いつもの通り苦肉の策で妥協しました。

以下、苦肉の策です。

・notification のレイアウトに Chronometer を入れる。
これだけです。
これだけで動くようになりました。

ただし、Chronometer(カウンターみたいなもん)をレイアウトのどこかに
表示しなければいけませんので、これが許容できない人はこの苦肉の策は
選択できません。
Chronometer を背景と同じ色にすれば見えなくなるかもしれませんが、実験はしていません。
invisible ではNGでした(アニメーションが止まりました)。

コードはこんな感じ
------ hoge.java ------
NotificationManager notificationManager = (NotificationManager)this.getSystemService(Service.NOTIFICATION_SERVICE) ;
if(notificationManager != null){
    Uri uri = Uri.parse("http://www.google.com/");
    Intent intent = new Intent(Intent.ACTION_VIEW,uri);
    PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);

    Notification notification = new    Notification(R.drawable.icon,"TEST",System.currentTimeMillis());
    RemoteViews contentView = new RemoteViews(getApplicationContext().getPackageName(),R.layout.notification);
    notification.contentIntent = pendingIntent;
    notification.contentView = contentView;
    notification.contentView.setTextViewText(R.id.status_text, "Some Status");
    notification.contentView.setTextViewText(R.id.status_text2, "doing something...");
    notification.contentView.setChronometer(R.id.text1,SystemClock.elapsedRealtime(), "%s ", true);
    notification.contentView.setProgressBar(R.id.status_progress, 100, 50, true);
    notificationManager.notify(1, notification);
}

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

       <LinearLayout
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:orientation="horizontal"
               >
               <ProgressBar
                       android:id="@+id/status_progress"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       style="@android:style/Widget.ProgressBar.Small.Inverse"
                       android:indeterminate="true"
                       android:layout_weight="0"
                       android:layout_gravity="center|center_vertical"
                       />
               <TextView
                       android:id="@+id/status_text"
                       android:textSize="18sp"
                       android:textColor="#000000"
                       android:layout_width="fill_parent"
                       android:layout_height="wrap_content"
                       android:layout_alignParentTop="true"
                       android:layout_weight="0"
                       android:layout_marginLeft="5dp"
                       />
       </LinearLayout>

       <LinearLayout
               android:layout_width="fill_parent"
               android:layout_height="wrap_content"
               android:orientation="horizontal"
               >
               <TextView
                       android:id="@+id/status_text2"
                       android:textSize="12sp"
                       android:textColor="#777777"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:layout_alignParentTop="true"
                       android:layout_weight="0"
                       />
               <Chronometer android:id="@+id/text1"
                       android:textSize="12sp"
                       android:textColor="#777777"
                       android:layout_width="wrap_content"
                       android:layout_height="wrap_content"
                       android:singleLine="true"
                       android:visibility="visible"
                       android:layout_gravity="right" android:gravity="right"
                       android:layout_weight="1"
                       />
       </LinearLayout>
</LinearLayout>


2011/11/07 に Xperia arc のアップデートが配信されました。
このアップデートでエリアメール(緊急地震速報など)が受信できるようになりました。

アップデートした後は自動的に受信する設定になっていますので、何もしなくても受信可能です。

設定は以下の手順で変更・確認が可能です。
・アプリ一覧から「エリアメール」をタップして起動
・メニューボタン(≡みたいなボタン)を押して「設定」をタップ
で「エリアメール受信設定」にチェックが付いていれば受信できます。

「着信動作確認」で実際に着信したときの挙動を確認できます。
緊急地震速報の音、けたたましいですね。
動作確認するときは大きい音がなりますので周りにご注意ください


Service から notification を発行し、notification をタップした際に activityを起動、そのactivity に値を渡したかったので以下のようなコードを書いた。

Notification notification = new Notification(R.drawable.icon,"Some message",System.currentTimeMillis());
Intent intent = new Intent(this, com.example.SomeActivity.class) ;
intent.putExtra("PARAM", 1) ;
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,intent,0);
notification.setLatestEventInfo(this.getApplicationContext(),"Some message","Some explanation",pendingIntent);
notificationManager.notify(mAppNo, notification);

受け側の activity では

Intent intent = getIntent();
someValue = intent.getIntExtra("PARAM", 0) ;

みたいな感じで値を取得しようと思ったら、取得できない。
というか、いつも同じ値になってしまう。

調べてみたところ PendingIntent を作るところで PendingIntent.FLAG_UPDATE_CURRENT
というフラグを指定してあげないと、古いものが再利用されるらしい。

第四引数を足して
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
としたら、うまく受け渡しできるようになりました。

1時間ハマりました。


FLEXのコンパイル環境を別のマシンにも作ろうと思って、
FLEX SDKをコピーして実行させたら以下のようなエラーになった。

Exception in thread "main" java.util.zip.ZipException: error in opening zip file
       at java.util.zip.ZipFile.open(Native Method)
       at java.util.zip.ZipFile.<init>(ZipFile.java:114)
       at java.util.jar.JarFile.<init>(JarFile.java:135)
       at java.util.jar.JarFile.<init>(JarFile.java:72)

JDK の bin のパスが 環境変数に設定されていないことが原因でした。

PATH 環境変数に JDK の bin ディレクトリを追加したらコンパイルできるようになりました。


android 2.3.3 のエミュレータにて
WebView に addJavascriptInterface でjavascriptを追加して呼び出すと以下のエラーを出力
して落ちます。

11-02 01:59:47.917: WARN/dalvikvm(783): JNI WARNING: jarray 0x405ac4d0
points to non-array object (Ljava/lang/String;)
11-02 01:59:47.917: INFO/dalvikvm(783): "WebViewCoreThread" prio=5 tid=9 NATIVE
11-02 01:59:47.917: INFO/dalvikvm(783):   | group="main" sCount=0
dsCount=0 obj=0x40526250 self=0x2b2d28
11-02 01:59:47.928: INFO/dalvikvm(783):   | sysTid=794 nice=0
sched=0/0 cgrp=default handle=2829920
11-02 01:59:47.928: INFO/dalvikvm(783):   | schedstat=( 443167172
624931535 187 )
11-02 01:59:47.928: INFO/dalvikvm(783):   at
android.webkit.WebViewCore.nativeTouchUp(Native Method)
11-02 01:59:47.928: INFO/dalvikvm(783):   at
android.webkit.WebViewCore.nativeTouchUp(Native Method)
11-02 01:59:47.928: INFO/dalvikvm(783):   at
android.webkit.WebViewCore.access$3300(WebViewCore.java:53)
11-02 01:59:47.928: INFO/dalvikvm(783):   at
android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1158)
11-02 01:59:47.928: INFO/dalvikvm(783):   at
android.os.Handler.dispatchMessage(Handler.java:99)
11-02 01:59:47.928: INFO/dalvikvm(783):   at
android.os.Looper.loop(Looper.java:123)
11-02 01:59:47.928: INFO/dalvikvm(783):   at
android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)
11-02 01:59:47.928: INFO/dalvikvm(783):   at
java.lang.Thread.run(Thread.java:1019)
11-02 01:59:47.928: ERROR/dalvikvm(783): VM aborting


調べたところ以下の通りエミュレータのバグとのことです。
http://code.google.com/p/android/issues/detail?id=12987

修正されるのを待ちましょう。
とりあえず動作確認は2.2のエミュレータで。

android で WebView を持つアクティビティを何個も起動したり閉じたりしているとプロ
セスが落ちてしまう端末がある。

logcat を見てみるとプロセスが落ちる前に
10-31 07:40:51.989: ERROR/webcoreglue(14026): The real object has been deleted
というエラーが出ていた。

調べてみたところ、Activityが終了するときに WebView の destroy も明示的に発行してやらないとこのエラーが起きるらしい。

ということで、activity の onDestroy を追加

protected void onDestroy() {
 mWebView.destroy();
 super.onDestroy();
}

で直りました。

このアーカイブについて

このページには、2011年11月に書かれたブログ記事が新しい順に公開されています。

前のアーカイブは2011年10月です。

次のアーカイブは2011年12月です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。

Powered by Movable Type 5.13-ja