- 将日志记录添加到您的 Droid1 项目。在 onCreate() 回调方法中,使用 Log.i() 方法添加信息性日志消息。运行应用程序并查看日志结果。
[例如,我应该在哪里输入“onCreate()”?在清单中?并在什么之下
- 除了 onCreate() 之外,还实现一些 Activity 回调方法,例如 onStart()、onRestart()、onResume()、onPause()、onStop() 和 onDestroy()。向每个回调方法添加日志消息,然后正常运行应用程序。查看日志结果以追踪应用程序的生命周期。接下来,尝试一些其他方案,例如暂停或挂起应用程序,然后恢复。模拟来电。观察应用程序日志以了解活动如何响应此类事件。
[我了解如何通过 DDMS 等模拟调用,但除此之外,我对在哪里键入该代码以及要包含哪些变量(如果有)一无所知。
我正在运行最新的 Android SDK 并使用 Eclipse。
编辑:不,这不是作业,这是来自山姆的自学书
编辑(修订版):一旦我得到这个..
公共无效onCreate(捆绑保存实例){
... 代码 ...
?
我应该在 Manifest.xml 中的哪里发布此内容 在诸如<的活动下活动>?
- Add a logging to your Droid1 project. Within the onCreate() callback method, add an informational logging message, using the Log.i() method. Run the application and view the log results.
[For example, where would I type "onCreate()"? In the manifest? and under what
- Implement some of the Activity callback methods in addition to onCreate(), such as onStart(), onRestart(), onResume(), onPause(), onStop(), and onDestroy(). Add a log message to each callback method and then run the application normally. View the log result to trace the application life cycle. Next, try some other scenarios, such as pausing or suspending the application and then resuming. Simulate an incoming call. Watch the application log to see how the activity responds to such events.
[ I understand how to simulate calls through the DDMS and etc., but other than that, I am clueless on where to type and of that code, and what variables if any to include.
I am running the latest Android SDK and using Eclipse.
EDIT: No this is not homework, this is from the Sam's Teach Yourself Book
EDIT(Revised): Once I get this..
public void onCreate(Bundle savedInstance) {
... code ...
}
where do I post this, in the Manifest.xml? under activity such as < activity >?
发布评论
评论(2)
Android SDK 使用 Java 作为编程语言。如果您熟悉 Java,您应该开始阅读以下内容:
Android 开发指南
android SDK 其(复制和粘贴)“[...]用户可以做的单一、集中的事情[...]”。这是完整的解释:
活动指南
祝你练习顺利: )
Android SDK uses Java as programming language. If you're familiar with Java you should start reading this:
Android Dev Guide
An activity in android SDK its (copy and paste) "[...]a single, focused thing that the user can do[...]". Here it is the whole explanation:
Activity guide
Good luck with your exercise :)
当您创建一个新的 Android 项目时,您将从一个模板活动开始,通常称为 MainActivity.java。
在此文件中,您将看到:
这是
onCreate()
方法。您可以更改... code ...
部分,并尝试使用书中的代码。尝试了一下之后,您可以继续学习更复杂的代码示例,例如 示例部分。
When you create a new Android project you will start out with a template activity, usually called MainActivity.java.
Inside this file you will see:
This is the
onCreate()
method. You can change the... code ...
part and try to use code from your book instead.After you've played around with that a bit you can move on to more complicated code examples, such as the Samples section of the sdk.