|
本帖最后由 熊猫儿 于 2013-2-22 10:21 编辑
2.将我们的调试代码嵌入工程
正如我们百度到的说明一样,在程序运行的开端加上 Debug.startMethodTracing(“yourActivityTrace”); 然后在onPause()中调用Debug.stopMethodTracing(); 为什么要将结束写在onPause()中而不写在onStop(),那么如果你去看api的话,你会看到,Api中介绍onPause()会在你返回和点击home按键后触发,而onStop()一般是由系统来触发,当该程序处于后台的时候,而且当内存紧张的时候,可能会调用,但是可能永远不会调用到!
备注:要记住当把调试代码加入项目中以后不要立即运行项目,而是必须在AndroidMainfest.xml中定义一条”写入SD卡的权限”那么添加权限的代码如下:
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”></uses-permission>
因为咱们的调试代码会在SD卡中生成一个追踪文件,也就是往SD卡中写入了数据,所以需要声明一条权限。这里必须注意哦!
[backcolor=rgb(248, 248, 248) !important]<?xml version="1.0"encoding="utf-8"?>
[backcolor=white !important]<manifest xmlns:android="http://schemas.android.com/apk/res/android"
[backcolor=rgb(248, 248, 248) !important] package="com.himi"
[backcolor=white !important] android:versionCode="1"
[backcolor=rgb(248, 248, 248) !important] android:versionName="1.0">
[backcolor=white !important] <applicationandroid:icon="@drawable/icon"android:label="@string/app_name">
[backcolor=rgb(248, 248, 248) !important] <activityandroid:name=".MainActivity"
[backcolor=white !important] android:label="@string/app_name">
[backcolor=rgb(248, 248, 248) !important] <intent-filter>
[backcolor=white !important] <actionandroid:name="android.intent.action.MAIN"/>
[backcolor=rgb(248, 248, 248) !important] <categoryandroid:name="android.intent.category.LAUNCHER"/>
[backcolor=white !important] </intent-filter>
[backcolor=rgb(248, 248, 248) !important] </activity>
[backcolor=white !important] </application>
[backcolor=rgb(248, 248, 248) !important] <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
[backcolor=white !important] <uses-sdkandroid:minSdkVersion="4"/>
[backcolor=rgb(248, 248, 248) !important]
|
|