約 5,247,090 件
https://w.atwiki.jp/anddoid/pages/20.html
Button 関連タグ 使用例 Button android id="@+id/button1" android layout_width="wrap_content" android layout_height="wrap_content" android text="Button" /
https://w.atwiki.jp/android_development/pages/23.html
Top 開発環境構築 4. Android SDKのインストール 4. Android SDKのインストール 以下のサイトからAndroid SDKをダウンロードする。 http //developer.android.com/sdk/index.html サイトの赤枠内のリンクをクリックすることでZipファイルをダウンロードします。 任意のフォルダに配置 ダウンロードしたファイルを任意のフォルダに解凍、配置します。 例:「C \Android\android-sdk-windows」 環境変数の設定を行います。 「android-sdk-windows\tools」へパスを設定します。 例:「C \android\android-sdk-windows\tools」 参考:http //blog.cnu.jp/2009/11/06/windows-7-path/ ※既に他のパスが存在する場合は「;」で区切る。 ↓↓↓ 解凍したフォルダ内の「android-sdk-windows\SDK Setup.exe」を起動 ↓↓↓ エラーがでたら以下のチェックボックスにチェックを入れます。 一度closeボタンを押し、左の欄内にあるsettingsを選択します。 ↓↓↓ window下部にあるmisc内の「Force~」にチェックします。 ↓↓↓ SDKのインストール 左の欄内にあるInstalld Packegeを選択し、赤枠内のUpdate All...ボタンを押します。 ↓↓↓ インストールしたいSDKにチェックを入れ、赤枠内の「Install Selected」をクリックします。 ↓↓↓ インストールが終了したらclosedボタンをクリックし終了します。 以上でAndroid SKDのインストールは終了です。 3. 戻る ← 4. Android SDKのインストール → 次へ Top 開発環境構築 4. Android SDKのインストール 広告
https://w.atwiki.jp/interaction_android/pages/15.html
@Android Project ここでは、大阪工業大学情報科学部のプロジェクトの1つであるAndroid Project Team[○○]の情報共有Wikiです. 基本的には、何かあればこちらを編集して、情報共有を行っていきたいと思います. 学内課題サイト(学内課題 http //interactiondesign.web.fc2.com/index.html) @目的(作成するもの) @会議結果 第1回 第2回 @方針 基本的にLineかSkypeで行う(リーダーのidea) 時間帯は @メンバー リーダー堤下 裕介 サブリーダー高 潔 プログラムリーダー野田 尚吾 デザインリーダー金元 優香 ビジネスモデルリーダー黒澤 一郎 他のメンバー大井 翔 幸 孝明 加藤 嘉寿 @デザイン @セットアップ セットアップページ @アンケートページ アンケート結果 @更新情報 日 付 内 容 2012/08/01 AndroidProjectページ開設 2012/08/03 Androidセットアップページ開設 2012/08/15 アンケート結果ページ開設
https://w.atwiki.jp/takenote/pages/23.html
11/05/08 android 環境整備メモ for mac 1 Android SDK install http //developer.android.com/sdk/index.html .profileへ export PATH=$PATH ~/android-sdk-mac/tools 追加 SDKコンポーネントのダウンロード(Android SDK2.0以降) ターミナルから ./android-sdk-mac/tools/android 実行 サイドメニュー"Settings" "Force https //...sources to be fetched using http //..." にチェック Save Apply サイドメニュー"Available Packages" ダウンロード対象をチェック "Android Repository" "Third party Add-ons" 必要なところにチェックを入れて、"Install Selected" android-sdk-mac/platform に保存される ADT(Android Development Tools)のインストール ADT Eclipse用のAndroidカスタムプラグイン Eclipse起動 [Help]-[Install New Software] Add ボタンを押す "Location"に https //dl-ssl.google.com/android/eclipse/ 入力 OK ボタンを押す 追加するツールのリストが表示されるので、 インストール対象にチェックマークをつけて Nextボタンを押す Install Details ウィンドウ - Next - ライセンス承諾 - Finish 2 Eclipse install http //www.eclipse.org/downloads/ [Eclipse] - [環境設定] "Android" 選択 "SDK Location" にSDKルートディレクトリのパス指定 Apply - OK
https://w.atwiki.jp/negilab/pages/15.html
Androidとは? Android Androidとは、GoogleおよびT-Mobile、HTC、モトローラ、日本からは KDDIやドコモを含む世界34社はオープン携帯プラットフォームを目指す団体「Open Handset Alliance」が開発を進める オープンソースのモバイルプラットフォーム。プログラミング言語はJava言語、開発環境はEclipseを使う。 UIはXMLレイアウトファイルで記述できる。 Androidはメーラー、SMS、カレンダー、地図、ブラウザなどのコアアプリケーションを含んで出荷される。 従来の携帯電話ではネイティブで入れ替えできなかった部分も作成できる模様。 アプリケーション実行環境というよりOSに近い印象を受ける。 特徴は次の通り。 アプリケーションフレームワーク コンポーネントの再利用が可能 Dalvik Virtual Machine モバイル用に最適化 統合ブラウザ WebKitベース グラフィックス 3DグラフィックスはOpenGL ES 1.0ベース SQLite ローカルデータをデータベース形式で保存 メディアサポート MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF GSM通話(機種依存) Bluetooth、EDGE、3G、WiFi(機種依存) カメラ、GPS、コンパス、加速度計(機種依存) デモはtoolsのemulator.exeを実行し、メニュー画面の「Application→App Demo」で閲覧可能。
https://w.atwiki.jp/android-reference/pages/22.html
android.app High-level classes encapsulating the overall Android application model. Interfaces DatePickerDialog.OnDateSetListener The callback used to indicate the user is done filling in the date. KeyguardManager.OnKeyguardExitResult Callback passed to exitKeyguardSecurely(KeyguardManager.OnKeyguardExitResult) to notify caller of result. PendingIntent.OnFinished Callback interface for discovering when a send operation has completed. SearchManager.OnCancelListener See setOnCancelListener(SearchManager.OnCancelListener) for configuring your activity to monitor search UI state. SearchManager.OnDismissListener See setOnDismissListener(SearchManager.OnDismissListener) for configuring your activity to monitor search UI state. TimePickerDialog.OnTimeSetListener The callback interface used to indicate the user is done filling in the time (they clicked on the Set button). Classes Activity An activity is a single, focused thing that the user can do. ActivityGroup A screen that contains and runs multiple embedded activities. ActivityManager Interact with the overall activities running in the system. ActivityManager.MemoryInfo Information you can retrieve about the available memory through getMemoryInfo(ActivityManager.MemoryInfo). ActivityManager.ProcessErrorStateInfo Information you can retrieve about any processes that are in an error condition. ActivityManager.RecentTaskInfo Information you can retrieve about tasks that the user has most recently started or visited. ActivityManager.RunningAppProcessInfo Information you can retrieve about a running process. ActivityManager.RunningServiceInfo Information you can retrieve about a particular Service that is currently running in the system. ActivityManager.RunningTaskInfo Information you can retrieve about a particular task that is currently "running" in the system. AlarmManager This class provides access to the system alarm services. AlertDialog A subclass of Dialog that can display one, two or three buttons. AlertDialog.Builder AliasActivity Stub activity that launches another activity (and then finishes itself) based on information in its component s manifest meta-data. Application Base class for those who need to maintain global application state. DatePickerDialog A simple dialog containing an DatePicker. Dialog Base class for Dialogs. ExpandableListActivity An activity that displays an expandable list of items by binding to a data source implementing the ExpandableListAdapter, and exposes event handlers when the user selects an item. Instrumentation Base class for implementing application instrumentation code. Instrumentation.ActivityMonitor Information about a particular kind of Intent that is being monitored. Instrumentation.ActivityResult Description of a Activity execution result to return to the original activity. IntentService An abstract Service that serializes the handling of the Intents passed upon service start and handles them on a handler thread. KeyguardManager Class that can be used to lock and unlock the keyboard. KeyguardManager.KeyguardLock Handle returned by newKeyguardLock(String) that allows you to disable / reenable the keyguard. LauncherActivity Displays a list of all activities which can be performed for a given intent. LauncherActivity.IconResizer Utility class to resize icons to match default icon size. LauncherActivity.ListItem An item in the list ListActivity An activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item. LocalActivityManager Helper class for managing multiple running embedded activities in the same process. Notification A class that represents how a persistent notification is to be presented to the user using the NotificationManager. NotificationManager Class to notify the user of events that happen. This is how you tell the user that something has happened in the background. PendingIntent A description of an Intent and target action to perform with it. ProgressDialog A dialog showing a progress indicator and an optional text message or view. SearchManager This class provides access to the system search services. Service A Service is an application component that runs in the background, not interacting with the user, for an indefinite period of time. TabActivity An activity that contains and runs multiple embedded activities or views. TimePickerDialog A dialog that prompts the user for the time of day using a TimePicker. Exceptions PendingIntent.CanceledException Exception thrown when trying to send through a PendingIntent that has been canceled or is otherwise no longer able to execute the request. コメント 名前 コメント すべてのコメントを見る
https://w.atwiki.jp/conn/pages/18.html
Androidプロジェクト Androidプロジェクトの中身を簡単にまとめます。 ネタ元はAndroid SDKのドキュメントと、EclipseのAndroid SDK Pluginで自動生成された雛形の動作検証です。 プロジェクトのディレクトリ構成 Androidアプリを作るなら、ごく当たり前の知識として知っておく必要があります。 プロジェクトルート src ソースコード用ディレクトリ gen ADTが自動生成したファイル用ディレクトリ。R.javaやAIDLファイルから生成されたファイルが該当。 assets 生のデータファイルを保存する。ビルド時にapkファイルへ組み入れられ、ファイルシステムと変わりない方法でアクセスできる。 bin ビルドされたファイル用ディレクトリres ビルドされたリソースファイル用ディレクトリ libs ライブラリファイル用ディレクトリ res リソースファイル用ディレクトリdrawable-**** 画像ファイルや、レイヤー定義などを記載した描画用定義XMLファイルを保存する。画面解像度ごとにディレクトリが分かれているモヨウ。 layout レイアウト定義XMLファイル用ディレクトリ menu メニュー定義XMLファイル用ディレクトリ values 文字列や設定情報等用のディレクトリ。resディレクトリ内の他のXMLファイルはファイル名ベースでアクセスするのに対し、XML要素を解析し、それぞれの要素名をR.javaファイルに展開しアクセスする点に違いがある。 raw 生のデータファイルを保存する。assetsディレクトリとの違いはアクセス方法で、こちらはR.javaファイルを通じてリソースファイルとしてアクセスする。 AndroidManufest.xml アプリの基本情報を定義する。アプリバージョン、製作者、対応・必要APIバージョン、必要な外部ライブラリなどなど、様々な情報を定義する。奥が深い。 リソースファイル用ディレクトリと、マニフェストファイルは、特に勉強が必要。 詳細が知りたければSDK Managerでドキュメントをインストールし読んでみると良い、全部英語だけども。 雛形プロジェクトの動作 ADTでプロジェクトを作成すると、HelloWorldが表示される簡単なアプリが出来上がった状態になっている。 その動作の細かな点をつついて、それぞれのディレクトリに格納されたファイルが どのように連携するかを調べてみた。 AndroidManifest.xmlを解析しアプリを起動、アクティビティの定義を読み込む。 XMLファイル中では「@」を用いることでリソースにアクセスすることができ、アプリケーション名やスタイル定義の指定に使用されている。 application android icon="@drawable/ic_launcher" <<<res/drawable-****/ic_launcher.pngファイルを参照 android label="@string/app_name" <<<res/valus/strings.xml内の文字列を参照 android theme="@style/AppTheme" <<<res/valus/style.xml内の定義を参照 activity android name=".MainActivity" <<<ここで起動するアクティビティを指定 android label="@string/title_activity_main" <<<res/valus/strings.xml内の文字列を参照 intent-filter action android name="android.intent.action.MAIN" / category android name="android.intent.category.LAUNCHER" / /intent-filter /activity /application binディレクトリ内のデフォルトアクティビティを起動する。 public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); <<<レイアウト定義ファイルを指定 } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); <<<メニュー定義ファイルを指定 return true; } } レイアウト定義ファイル res/layout/activity_main.xml メニュー定義ファイル res/menu/activity_main.xml Activityの動作に従い読み込まれる。 それぞれの定義ファイルにはリソースへのアクセスが指定されている。 TextView android layout_width="wrap_content" android layout_height="wrap_content" android layout_centerHorizontal="true" android layout_centerVertical="true" android text="@string/hello_world" tools context=".MainActivity" / menu xmlns android="http //schemas.android.com/apk/res/android" item android id="@+id/menu_settings" android title="@string/menu_settings" android orderInCategory="100" android showAsAction="never" / /menu 以上が簡単な動作解説です。 マニフェストファイルが起点となり、アクティビティが実際の動作を担っており、 動作時に様々な箇所でリソース内の定義ファイルが読み込まれているのが分かる。 Webアプリケーションなどに比べると非常に単純な構成となっているが、アプリが大きくなるとファイルが増え、管理が難しくなりがち。だがディレクトリ構成の原則に従いアプリを作成することで、誰にでも分かりやすい、無論のこと自分自身にも分かりやすい管理しやすい構成にできる。
https://w.atwiki.jp/derax7/pages/18.html
Android クリックイベント Button start = (Button) findViewById(R.id.start); start.setOnClickListener(new OnClickListener() { public void onClick(View v) { //処理 } }); 状態保持 // ハイスコア読み込み SharedPreferences pref; pref = this.getSharedPreferences("PreferencesEx", Activity.MODE_PRIVATE); int stage = pref.getInt("stage", 0); // ハイスコアの書き込み pref = getContext().getSharedPreferences( "PreferencesEx", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); editor.putInt("stage", level); editor.commit(); isFinishing()で終了状態取得 isFinishing()を利用すると、Activityの終了状態を判別できる 画面遷移の種類 -Intentを飛ばした場合 false -ホームボタンを押した場合 false -戻るボタンを押した場合 true Androidで音を鳴らす。[SoundPool編] SoundPoolクラスの場合、基本は下記の3処理。 ①SoundPoolを new して、 ②音声ファイル読み込んで、 ③再生する SoundPool soundPool = new SoundPool(5,AudioManager.STREAM_MUSIC, 0); // ① int soundID = soundPool.load(context, R.raw.lalala, 1); // ② soundPool.play(soundID, 1.0F, 1.0F, 1, 0, 1.0F); // ③ 【①の補足】 public SoundPool (int maxStreams, int streamType, int srcQuality) 引数: maxStreams … このSoundPoolオブジェクトで同時に扱う音声(Stream)の最大数 streamType … 音声(stream)の種類。 AudioManagerクラスに定義されている srcQuality … サンプルレートの質。(現在はまだ未使用。 0 を使えとのこと) 返り値: 成功なら、SoundPoolオブジェクト 失敗なら、null 【②の補足】 音声ファイルは、res/raw/lalala.ogg に設置したという想定。ResourceIDは R.raw.lalala になる。ここから想像できると思うが、同フォルダに lalala.wav や lalala.mp3 を設置しても区別がつかない。 ちなみに、音声ファイルを安定再生するためには oggファイルが良いとのこと。 public int load (Context context, int resId, int priority) 引数: context … コンテキスト resId … 音声ファイルのリソースID priority … 優先度サンプルレートの質。(現在はまだ未使用。将来互換性のため 1 を使え) 返り値: sound ID (再生時に使用) 【③の補足】 public final int play (int soundID, float leftVolume, float rightVolume, int priority, int loop, float rate) 引数: soundID … load()メソッドで返される soundID leftVolume … 音量[左] (範囲:0.0~1.0) rightVolume … 音量[右] (範囲:0.0~1.0) priority … ストリーム優先度 (0 = 優先度最低) loop … ループの回数 (0 = ループ無し、-1 = 無限ループ) rate … 再生レート (1.0 = 標準の再生, 範囲:0.5~2.0) 返値 成功なら、streamID(≠0) 失敗なら、0 IntentへのExtra付加 intent.putExtra("hoge", String s); getIntent().getExtras().getString("hoge"); drawableからbitmap変換 Resources res = this.getResources(); // 画像の読み込み Bitmap bm = BitmapFactory.decodeResource(res, R.drawable.blue); Intent時のタスクについて マニフェストでアクティビティに以下のオプションを追加すると、シングルタスク(新タスクを別タスクとして記憶せず、自身に積み重ねる)モードになる。HOME画面等に設定。 android launchMode="singleTask" アイコンの作成 http //android-ui-utils.googlecode.com/hg/asset-studio/dist/index.html Spinnerの初期値設定 spinner.setSelection(0); プログレスダイアログ progressDialog = new ProgressDialog(CoordinateActivity.this); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setMessage("処理を実行中です..."); progressDialog.setCancelable(true); progressDialog.show(); (・・・処理・・・) progressDialog.dismiss(); ダイアログのカスタム OnCreateDialog(int id){・・・}内でレイアウト等の適用ができる。ダイアログ生成前に呼び出され、returnでダイアログを返してやる ボタンへのクリックリスナー追加 (Button)btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(GalleryActivity.this, Main.class); startActivity(intent); } }); エラー関連 以下のエラーがでた時はどうやらメモリリークっぽい。 端末再起動で直るけど、リーク箇所の特定をしたほうがよさそう Failed to install XXX.apk on device HT0B8RX02778 Too many open files 【View】子Viewの追加&削除 追加:view.addView(child); 削除;view.removeView(child); 全削除:view.removeAllViews(); カメラにIntentを飛ばして起動 // Intent for Camera Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(i, REQUEST_CODE_CAMERA); 保存先はExtraで指定 File tmpPict = new File(Environment.getExternalStorageDirectory(), "/hogehoge/" + System.currentTimeMillis() + ".jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(tmpPict)); 結果をActivityResultで受け取り処理。 @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQUEST_CODE_CAMERA) { 【View】layout.xmlの読み込み setContentView(R.layout.main); これは View v = this.getLayoutInflater().inflate(R.layout.main, null); setContentView(v) と置き換えられる(→addView()などに) 端末画面サイズ取得 WindowManager wm = (WindowManager)getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Log.d("display", "w " + display.getWidth()); Log.d("display", "h " + display.getHeight()); ロケールの取得 Locale locale = Locale.getDefault(); Log.v("ロケールは", locale.toString()); 以下のようにロケール別に分岐できる if (locale.equals(Locale.JAPAN)) { ・・・・・ } 画面遷移 intentを飛ばして画面遷移 Intent intent = new Intent(this.context, 遷移先.class); startActivity(intent); ※manifestへのactivityの追加を忘れないこと! 【View】idから呼び出し TextView textViewData = (TextView)findViewById(R.id.hoge); textViewData.setText("hogehoge"); onClick()内でのボタン選別 @Override public void onClick(View v) { switch (v.getId()) { case R.id.button_animation Intent intent = new Intent(this, Animation.class); startActivity(intent); break; case R.id.button_sub Intent intent2 = new Intent(this, Sub.class); startActivity(intent2); break; default break; } } SharedPreference云々 SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(this); Editor ed = SP.edit(); AdMob 最近仕様が変わったらしい AdMob導入の注意点 アニメーション private Handler myHandler = new Handler() { @Override public void handleMessage(Message msg) { if (isAttached) { // 移動処理 move(); // 再描画 invalidate(); sendEmptyMessageDelayed(0, DELAY_MILLIS); } } }; http //www.adamrocker.com/blog/181/android_animation.html
https://w.atwiki.jp/devandroidknowledge/pages/14.html
≪Android Tips≫ ◆なんと、Androidには温度センサーが付いているみたい! 【温度センサーから温度を取得するには(概要)】 Sensorインスタンスの生成 Sensorインスタンスに温度センサーを指定する SensorManagerインスタンスにリスナ―指定する。( 温度変化があったごとに記録するには、左記にプラスして下記が必要。) Andoridのセンサーには加速度センサーとか磁気センサーなどがある リスナーに設定すると、センサーの値が変更されたタイミングでonSensorhangedというメソッドが呼び出され、センサーの値を取得することが出来る。 SensorManagerインスタンス センサーを管理するためのSensor系のインスタンス。センサーを管理するためのメソッドも用意されている。 【温度センサーから温度を取得するには(詳細)】 getSystemServiceメソッドでSensorManagerインスタンスを取得 SensorManager.getDefaultSensorメソッドにSensor.TYPE_TEMPERATURE(温度センサー)を指定する。 SensorManager.registerListenerメソッドに②で生成したSensorインスタンスを指定。 by nakamura ◆GoogleMap活用法系 GoogleMap使用準備 GooglMapAPIのKeyを取得する。 AndroidManifestにインターネット接続のパーミッションとGooglMaoAPIを利用する記述を行う。 GoogleMap使用準備 さぁ、準備が出来たら画面に表示だ! 画面に表示させるにはあ以下のことを行う必要がある。 MapActibityクラスの継承 そのクラスの中でonCreateするときにsetContentView(R.layout.main)で地図をセットする。 ※main.xmlにMapViewを配置しておく。 ※MapView・・・Googleから取得したAPIキーの記述や、地図に関する表示をクリックの可否の記述を行う isRouteDisplayedメソッドをオーバーライドしてfalseを返すようにする ※isRouteDisplayedメソッド・・・?? ※MapViewインスタンスからマップ表示させることも可能 MapView mapView = new MapView(this,getResources().getString(取得したキー)); mapView.setEnabled(true); mapView.setClickable(true); setContentView(mapView); by nakamura ◆画面系いろいろ入門編 1画面につき1つActivityクラスが対応する。 バックグラウンドの処理はServiceクラスに実装する。 AvtivityからService,ServiceからServiceを呼び出す際はIntentを使う。 アプリ起動時の画面はAndroidManifest.xmlのintent-filterに設定する。 参考にしたページ Androidアプリ作成のための基礎知識 Androidプログラミング入門 Android入門
https://w.atwiki.jp/android/pages/136.html
ネット上に公開されているAndroidアプリケーションの索引 ※基本的にソース、あるいはapkファイルが公開されているもの。 ツール タスクマネージャ SDK version Task manager primitive prototype m3-rc37a以前 メディアプレイヤー Video/Music player sample (from local disk as well as remote URL’s) m3-rc37a以前 メール Send email via GMail (actually via SMTP) m3-rc37a以前 GoogleTalk Totally *Unofficial* Android GTalk Client (Send/Receive XMPP Messages) m3-rc37a以前 Android用Google Talkクライアントをm5-rc14に移植 m5-rc14 Mame Talk Ver.0.8 m5-rc14 Twitter Twitter Client for Android (How to make XML over HTTP calls) m3-rc37a以前 #ref error :ご指定のファイルが見つかりません。ファイル名を確認して、再度指定してください。 (TwitterClient3.png) AndroidでTwitterクライアント ver.3 m3-rc37a以前 地図関連 Androidで地図アプリケーションを作ってみた m3-rc37a以前 Androidの地図アプリをぐるなびに対応しました m3-rc37a以前 Androidの地図アプリをm5-rc14っぽくしてみた m5-rc14 ビューア ComicViewer3 -Androidで電子ブックリーダ m3-rc37a以前 Android用電子ブックリーダをm5-rc14に移植 m5-rc14 ゲーム テーブルゲーム AndroidとFlickrで神経衰弱 m3-rc37a以前 ブロック崩しをm5-rc14に移植 m5-rc14 その他 アンドロイド・アプリケーション こめんと なるべく集めて回るけど作ったひとが自発的に追加してくれるとありがたいなあ - kojira 2008-02-12 21 54 53 プラグイン追加とかが自分で出来ないから不便だなあ。そのうち移転するかも。 - kojira 2008-02-18 23 09 07 名前