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

aaptの使い方

1$ <sdk>/platform-tools/aapt dump badging <path_to_exported_.apk>
2,931 views

役立つサイト

http://techbooster.jpn.org/

http://www.adakoda.com/android/

http://www.taosoftware.co.jp/android/android.html

1,544 views

文字入力ダイアログ

文字の入力欄をダイアログで表示します。

1EditText editView = new EditText(this);
2 
3new AlertDialog.Builder(this)
4    .setIcon(R.drawable.ic_dialog_info)
5    .setTitle("ダイアログのタイトル")
6    .setView(editView)
7    .setPositiveButton("OK", new DialogInterface.OnClickListener() {
8        public void onClick(DialogInterface dialog, int whichButton) {
9            // OKボタンの処理
10        }
11    })
12    .setNegativeButton("キャンセル", new DialogInterface.OnClickListener() {
13        public void onClick(DialogInterface dialog, int whichButton) {
14        }
15    })
16    .show();
4,733 views

カメラパラメーターの色々

参考になります。
http://developer.android.com/intl/ja/reference/android/hardware/Camera.Parameters.html

2,373 views

GPS機能設定の状態を取得(ネットワーク)

GPS機能についてはこちら1828

端末自身の[設定]-[位置情報とセキュリティ]より、「Wi-Fi/モバイルネットワークで位置を検出」がONに設定されているかを取得します。
OFFに設定されている場合にダイアログを表示して設定画面を呼び出す処理をしています。

1// 位置情報設定の状態を取得
2String GpsStatus = android.provider.Settings.Secure.getString(getContentResolver(), Secure.LOCATION_PROVIDERS_ALLOWED);
3 
4if (GpsStatus.indexOf("network", 0) < 0) {
5  //Wi-Fi/モバイルネットワークで位置を検出が無効だった場合
6  AlertDialog.Builder ad = new AlertDialog.Builder(this);
7  ad.setMessage("Wi-Fi/モバイルネットワークで\n位置を検出する機能がOFFになっています。\n設定画面を開きますか?");
8  ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {
9    public void onClick(DialogInterface dialog, int whichButton) {
10      //設定画面を呼び出す
11      Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
12      startActivity(intent);
13    }
14  });
15  ad.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
16    public void onClick(DialogInterface dialog,int whichButton) {
17      //何もしない
18      }
19  });
20  ad.create();
21  ad.show();
22} else if {
23} else {
24  //有効だった場合
25}

API Level3(Android 1.5)以降、セキュリティ上の問題で設定を強制的に変更することはできません。

4,040 views