約 5,497,469 件
https://w.atwiki.jp/android-reference/pages/23.html
public class Activity since API Level 1 extends ContextThemeWrapper implements ComponentCallbacks KeyEvent.Callback Layoutlnflater.Factory View.OnCreateContextMenuListener Window.Callback java.lang.Object ↳ android.content.Context ↳ android.content.ContextWrapper ↳ android.view.ContextThemeWrapper ↳ android.app.Activity Known Direct Subclasses ActivityGroup, AliasActivity, ExpandableListActivity, ListActivity Known Indirect Subclasses LauncherActivity, PreferenceActivity, TabActivity Class Overview An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View). While activities are often presented to the user as full-screen windows, they can also be used in other ways as floating windows (via a theme with windowIsFloating set) or embedded inside of another activity (using ActivityGroup). There are two methods almost all subclasses of Activity will implement onCreate(Bundle) is where you initialize your activity. Most importantly, here you will usually call setContentView(int) with a layout resource defining your UI, and using findViewById(int) to retrieve the widgets in that UI that you need to interact with programmatically. onPause() is where you deal with the user leaving your activity. Most importantly, any changes made by the user should at this point be committed (usually to the ContentProvider holding the data). To be of use with Context.startActivity(), all activity classes must have a corresponding activity declaration in their package s AndroidManifest.xml. The Activity class is an important part of an application s overall lifecycle, and the way activities are launched and put together is a fundamental part of the platform s application model. For a detailed perspective on the structure of Android applications and lifecycles, please read the Dev Guide document on Application Fundamentals.
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/bagpack/pages/15.html
Google Android プログラミング入門メモ Activityの作成 手順1 新しいリソースの定義(string.xmlとlayout/hogehoge.xml) 新しいActivityクラスのコーディング 新たに作成したActivityクラスをマニフェストファイルに追記 Activity間でのデータの受け渡しはintentでも使えばおk SharedPreference データの共有ができる。引数で共有する範囲を設定することもできる。 共有データのセット SharedPreferences preferences = getSharedPreferences("SHARED_NAME", MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putInt("SHARED_DATA", shared_data); editor.commit(); setResult(RESULT_OK); finish(); 共有データの読み込み SharedPreferences preferences = getSharedPreferences("SHARED_NAME", MODE_PRIVATE); String shared_data = preferences.getString("SHARED_DATA", 0); // shared_dataがstring型なら BroadcastReceiver ブロードキャストされたインテントに反応する仕組み。 次のようにして作成する。 レシーバクラスの作成 public class MyIntentReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle bundle = intent.getExtras(); ... } } マニフェストファイルの定義 ここでレシーバの登録や、インテントフィルタの定義を行う。 アクション名のプリフィックスには、パッケージ名をいれることが推奨されている(気がする)。 receiver android name=".MyIntentReceiver" intent-filter action android name="packagename.intent.action.ACTION_NAME" / category android name="packagename.intent.category.CATEGORY_NAME" / /intent-filter /receiver ブロードキャスト送信する方 Intent intent = new Intent("packagename.intent.action.ACTION_NAME"); ... intent.putExtra("DATANAME", data); sendBroadcaset(intent);
https://w.atwiki.jp/sevenlives/pages/2431.html
Activity(Android) 読み:あくてぃびてぃ 英語:Activity 別名: 意味: Activityとは、Androidアプリケーションにおいて画面にあたるオブジェクトのこと。 Androidアプリケーションを開発する場合はこのActivityが基本となります。 2012年01月25日 Fragments(Android) Action Bar Android
https://w.atwiki.jp/android/pages/28.html
概要 Activity は androidに表示される画面の単位。 ただしダイアログなどは含まない。ヒストリの扱いが違う。 ベースクラスのContext に色々と便利な機能が用意されている。 ライフサイクル 作成、可視、対話中 という3つの状態を遷移する。あとヒストリの関係でonFreezeとonRestartが存在する。 onCreate Activityが作成された。 UIの初期化 Bundleからデータを読む onStart Activityの表示が開始される。 初回はonResumeに続く。 もしonStop()の後に再開した場合はonRestart()に続く。 onRestart Activityの表示の再開。 初回 onCreate()→onStart() →onResume() それ以外 onStop()→onStart()→onRestart()→onResume() onResume Activityはユーザとの対話を開始する。 onFreeze Activityはユーザとの対話を中断する。 データの永続化を行うこと。 Bundleにデータを保存 常にonPauseに続く。 onPauseとの主な違いはヒストリスタック上の扱い。android.content.IntentReceiverを参照。 onPause Activityはユーザとの対話を中断する。 アニメーション表示の停止などを行うこと。 対話が再開する場合はonResumeに続く。 非表示状態が続いた場合はonStopに続く。 onStop Activityは表示を中断する。 ActivityはonStartとonRestartの呼び出しの後に再開するか、 onDestroyの呼び出しの後に破棄される。 また、他のアプリケーションがメモリを要求した場合はプロセスごとkillされる。 onDestroy Activityが破棄される。 finish()からも呼ばれるため、区別のために isFinishing() メソッドが用意されている。
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/21.html
このページは現在作成中です Androidアプリの基本構成 Androidアプリは幾つかのコンポーネントを組み合わせて作成する。コンポーネントはその役割ごとに幾つかに分類される。 Androidアプリを構成する4つのコンポーネント もっとも基本的なコンポートネントは次の4種類。 Activities 画面。アクティビティはそれぞれが独立したコンポーネントとして作成され、その組み合わせでアプリを動作させる。別のアプリから、また別のアプリ内のアクティビティを動作させることも可能。 Services 裏側でこっそり働く子。ユーザーインターフェースは持たない。ネットワークからデータをダウンロードしてきたり、別のアプリを操作中に音楽ファイルを再生したり、ユーザーの操作を邪魔することは無い。アクティビティのような他のコンポーネントから起動され、動作を指定される、サービス精神の塊のような存在。 Content Providers アプリケーションのデータへのアクセス共有を管理しデータの読み書きを行う。ファイルシステムやSQLiteなどのDB、インターネット上のデータなど、さまざまな場所に対応する。許可すれば他のアプリからデータの読み書きが可能だし、その逆も可能。動画を配信してくれる業者ではない。 Broadcast Reciever システムからの通知を受け取ったり、システム全体へ通知を発信したりする。例えばスリープに入った、バッテリーが切れ掛かっている、写真を撮った、などなどの通知を受けたり、発信したりできる。 電話を自動録音するアプリなんかだと、電話が掛かってきたという通知を受けサービスを起動し録音する、という使い方が想定される。 他にもコンポーネントには分類されないが、Androidアプリを構成する重要な要素がある。 マニフェスト アプリに属するコンポーネントを規定するのがマニフェストファイル。XML形式で記述する。 Intentフィルターで、アプリのエントリポイント(初期起動するアクティビティ)を指定する。 例:雛形アプリの AndroidManifest.xml。Intentフィルターが Activityの子要素で指定されている。 activity android name=".MainActivity" android label="@string/title_activity_main" intent-filter action android name="android.intent.action.MAIN" / category android name="android.intent.category.LAUNCHER" / /intent-filter /activity 他にも幾つかのIntent Filterアクションおよびカテゴリーがあるが、アプリアイコンから起動する場合はこの指定が必要だと覚えておけばよい。 他のアプリから 特定の Intentアクションにより起動されるアプリは、別の指定を追加する必要がある。 Intent(インテント:意図) 特定のアクティビティを指定、または「何をしたいのか」を指定し別のアプリを起動する。 同アプリ内のアクティビティ間連携にも使用される。 例:明示的に特定のアクティビティを指定し、EditTextボックスの入力値を渡している Intent intent = new Intent(this, DisplayActivity.class); EditText editText = (EditText) findViewById(R.id.input_message); String message = editText.getText().toString(); intent.putExtra(EXTRA_MESSAGE, message); startActivity(intent); 例:データ表示を指定し、Webページを開く Uri uri = Uri.parse("http //www.android.com"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); 簡略化のため省いているが、通常は事前に実行可能なIntentかチェックするためPackageManagerを使用する。この Intentで開かれるアプリは Intent Filterにて ACTION_VIEWアクションを受け付ける指定があるものの中から選ばれる。 リソース アプリが利用する画像ファイル、レイアウト定義、言語ごとの文字列ファイルなどをひとまとめにし、Rクラスを通じた共通のアクセス方法を提供する。画像、動画、音声などのデータファイル、XMLファイルで構成される。 リソースは異なる解像度、画面サイズ、言語に対応するディレクトリに分けて構成することで自動的に対応するディレクトリ内のファイルが利用されるように最適化される。詳細はこちら その他 基本の4コンポーネント種とリソースの他に、これらをサポートするコンポーネントが幾つかある。 Intent Fragment
https://w.atwiki.jp/anddoid/pages/63.html
activity 関連タグ 使用例 activity android name=".StartActivity" android label="@string/app_name" intent-filter action / category / /intent-filter /activity activity android name=".MainActivity" /activity
https://w.atwiki.jp/taskeru/pages/34.html
Taskerから直接実行すると便利なActivity misc component activity で利用可能 アプリ名 動作 指定Activity ジョルテ 新規作成 jp.co.johospace.jorte.gcal.EditEvent ビジネスカレンダー 新規作成 net.geniusbizcal.NewEditEventActivity SwipeSwitcher 前のアプリに戻る(除外リストあり) com.appspot.eikatou0.ss.TaskSwitchActivity PowerAMP ライブラリ表示(通常設定はplayerにして、これもswipepadに登録すると捗る?) com.maxmpz.audioplayer.PlayListChooser OS標準 無くしたときのためのデータリセット com.android.settings.SecFactoryReset 2chMate 巡回Sync2ch同期p2同期 jp.syoboi.a2chMate.action.reloadBookmarkjp.syoboi.a2chMate.action.sync2chjp.syoboi.a2chMate.action.p2sync Intent リスト一覧を表示するアプリ GetIntentList Activity Getter マケにある intent intercept は、実際に intent が発動する毎にそれがどんな挙動をしているか、他に同じ intent を受信出来るアプリはどれなのかを表示してくれる こちらは、アプリ上でコピーも出来る Intent Intercept QuickShortcutMaker で実際に動かせるが… data や extra は渡せない
https://w.atwiki.jp/wikiroid/pages/56.html
作者 AnderWeb URL http //jp.androlib.com/c.aspx?i=FEjB u=aHR0cDovL3d3dy5qYnRoZW1lcy5jb20vYW5kZXJ3ZWIv Ver 1.3.6 言語 日本語 Link アンドロイダー http //androider.jp/?p=12938 AndroLib http //jp.androlib.com/android.application.org-adw-launcher-FEjB.aspx