カテゴリー
SugiBlog Webエンジニアのためのお役立ちTips

Shell起動したアプリケーションの終了を待つ

Dim oShell As Object, oExec As Object

'オブジェクト変数に参照をセットします
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec("C:\example.exe")

'処理完了を待機
Do Until oExec.Status: DoEvents: Loop

'戻り値をセット
If Not oExec.StdErr.AtEndOfStream Then
	ExecCommand = True
	sResult = oExec.StdErr.ReadAll
ElseIf Not oExec.StdOut.AtEndOfStream Then
	sResult = oExec.StdOut.ReadAll
End If

'オブジェクト変数の参照を解放
Set oExec = Nothing: Set oShell = Nothing

'結果を表示
MsgBox sResult
7,598 views

Webサービスとの連携

org.apache.httpクラスを使ってHTTP通信をおこないます。

AndroidManifest.xmlにインターネット接続許可の記述を追加します。

<uses-permission android:name="android.permission.INTERNET" />

Getメソッド

public String doGet( String url )
{
    try
    {
        HttpGet method = new HttpGet( url );

        DefaultHttpClient client = new DefaultHttpClient();

        // ヘッダを設定する
        method.setHeader( "Connection", "Keep-Alive" );

        HttpResponse response = client.execute( method );
        int status = response.getStatusLine().getStatusCode();
        if ( status != HttpStatus.SC_OK )
            throw new Exception( "" );

        return EntityUtils.toString( response.getEntity(), "UTF-8" );
    }
    catch ( Exception e )
    {
        return null;
    }
}

続きを読む…»

6,957 views

アイコンの表示がおかしいとき

アイコンキャッシュのファイル「IconCache.db」を削除し、再起動します。

C:\Documents and Settings\Administrator\Local Settings\Application Data
2,457 views

Androidアプリ公開

Androidアプリ「たびろく」を公開しました。
https://market.android.com/search?q=tabiroku&c=apps

「たびろく」は旅の思い出を記録するアプリです。
タイトルとコメントを付けて保存することができ、それをそのままmixiやFacebook等のメール更新が可能です。

1,714 views

設定項目を無効にする Preference

PreferenceActivityのonCreateで処理します。
例では条件を何も指定していませんが、任意に条件を指定して実装してください。

例)チェックボックスの設定項目を無効化

PreferenceScreen prefScreen = getPreferenceScreen();
CheckBoxPreference checkboxPreference = 
    (CheckBoxPreference)prefScreen.findPreference("key");
checkboxPreference.setEnabled(false);

子項目として親項目と依存関係を持たせる場合

PreferenceScreen prefScreen = getPreferenceScreen();
CheckBoxPreference checkboxPreference = 
    (CheckBoxPreference)prefScreen.findPreference("key");
checkboxPreference.setDependency("親項目のkey");

xmlで指定

android:dependency="親項目のandroid:key"
9,433 views