开发者

Toast message only in Testing

I am android newbie.

I made a simple program, and I used Toast code for checking if variable is correct or not. After finishing test, I have to remove all the Toast code to release app. I think there must be m开发者_JAVA百科ore effective and better way to do this.

please help me

thank you in advance.


Use LogCat. You can output values to LogCat output using Log.d in your code. You can read detailed information about LogCat and logging here Debugging in Android using Eclipse


If you use ant, you can have define some parameter like build.debug in build.properties files, you will need to have two different files build_dbg.properties and build_rel.properties.


I would extend the Log class and redirect everything to android.Log. In your own implementation you can then fire the Toast.

You will need to pass the Context and maybe execute it on UI thread.


If you use Log.[vdiwe], you should consider to use Androlog. It does the same as the default android Log class, but you can switch it of when you release your app later on.

It also supports some kind of reporting mechanism, which I did not test up to now, but looks promising.


I’ve never bothered with the Log class, because I found that everything written to System.err appears in the Android log regardless.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜