1

重複の可能性:
Android アクティビティのライフ サイクル - これらすべてのメソッドは何のためのものですか?

メインと呼ばれるmenuActivityアクティビティと、と呼ばれる別のアクティビティがありbirthDateます。

アプリケーションを実行するmenuActivityと がアクティブになり、ボタンをクリックすると 2 番目のアプリケーションがアクティブになり、birthDate.

私の質問は:

最初のアクティビティがアクティブになると、別のアクティビティがバックグラウンドになり、メイン アクティビティがフォアグラウンドになります。どのメソッドを実装する必要がありますか? OnResumeまたはOnCreateまたは何ですか?

4

6 に答える 6

5

onResume ..次のhttp://developer.android.com/training/basics/activity-lifecycle/index.htmlを確認してください ここに画像の説明を入力

于 2012-12-19T07:39:59.990 に答える
4

Android ドキュメントを読んで、アクティビティのライフサイクルを理解してみてください

http://developer.android.com/training/basics/activity-lifecycle/pausing.html

リンクから下の画像のように

ここに画像の説明を入力

于 2012-12-19T07:40:08.757 に答える
4

実装する必要があるのは onResume です。

この Android アクティビティのライフサイクルを見てください。

ここに画像の説明を入力

于 2012-12-19T07:40:28.317 に答える
2

http://developer.android.com/reference/android/app/Activity.htmlを読む必要があり ます。探しているメソッドは onResume() です。

于 2012-12-19T07:40:41.390 に答える
2

アクティビティが再開したときに何らかのアクションを実行したい場合は、アクティビティがフォアグラウンドになるたびに呼び出されるメソッドであるonResume()ため、コードを内部に配置する必要があります。アクティビティの有効期間中に 1 回だけ呼び出されます。onResume()onCreate()

于 2012-12-19T07:40:52.880 に答える
0

システム内のアクティビティは、アクティビティスタックとして管理されます。新しいアクティビティが開始されると、それはスタックの一番上に配置され、実行中のアクティビティになります。前のアクティビティは常にスタック内のその下に残り、新しいアクティビティが終了するまで再びフォアグラウンドになりません。

アクティビティには、基本的に4つの状態があります。

**If an activity in the foreground of the screen (at the top of the stack), it is active or running.**

**If an activity has lost focus but is still visible (that is, a new non-full-sized or transparent activity has focus on top of your activity), it is paused. A paused activity is completely alive (it maintains all state and member information and remains attached to the window manager), but can be killed by the system in extreme low memory situations.**

**If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere.**

**If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process. When it is displayed again to the user, it must be completely restarted and restored to its previous state.**

次の図は、アクティビティの重要な状態パスを示しています。四角い長方形は、アクティビティが状態間を移動するときに操作を実行するために実装できるコールバックメソッドを表します。色付きの楕円は、アクティビティが存在できる主要な状態です。

ここに画像の説明を入力してください

于 2012-12-19T07:54:29.777 に答える