Android 设计思想
2010-06-17 03:29:00 来源:WEB开发网The “Android Way” is to create a ContentProvider to expose your data to other applications via a clean, well-thought-out, and maintainable API. Using a ContentProvider is much like inserting a Java language interface to split up and componentize two tightly-coupled pieces of code. This means you’ll be able to modify the internal format of your data without changing the interface exposed by the ContentProvider, and this without affecting other applications.
如果你穿着内裤是不会走在街上的,你的数据也是如此。或许可以暴露给确定的几种类型的程序,这通常不是最佳的方法。暴露有规律的数据需要其他程序能够知道你的数据格式。如果你改变了格式,你将破坏那些没有得到同步更新的程序。 ”Android 的方法“ 是通过一套简洁的、深思熟虑的、可维护的API来创建一个ContentProvider(内容提供者)来暴露你的数据给其他程序。使用 ContentProvider 很像插入Java 语言接口分割和组合两段紧密耦合的代码。这意味着您将是能修改您的内部数据格式而不用改变由ContentProvider 暴露接口, 你的改变不会影响其它应用。
不要打断正在通话中的用户
If the user is running an application (such as the Phone application during a call) it’s a pretty safe bet he did it on purpose. That’s why you should avoid spawning Activities except in direct response to user input from the current Activity.
That is, don’t spawn Activities from IntentReceivers or Services running in the background. Doing so will interrupt whatever application is currently running, and result in an annoyed user. Perhaps even worse, your Activity may become a “keystroke bandit” and receive some of the input the user was in the middle of providing to the previous Activity. Depending on what your application
更多精彩
赞助商链接