android 一起关闭
In today’s time, Android is something that is dominating the smartphone market. Right now Android is something that is considered to be old since it became available for development around 19 years ago for developers. Since then it has evolved for the better, starting with Eclipse and then gradually moving to Android Studio in 2013. It started with a couple of hundred developers and now there are almost 12 million worldwide. The main reason for such a vast number is that Android Studio has made developing so much easier that literally anyone can learn it and launch an app on the app store within a month(tho your app might not be that good, but still it’s the ability to have something of your own to the world that counts).That’s where I come in. I started Android because I was amazed by the idea of how an app can bring about a big difference to the world. I had been coding in java for a long time so it was a pretty smooth transition for me. I started by learning a bit of XML(don’t worry it’s super easy) and then developed a bunch of stereotypical starter apps like a scheduler, calculator, etc. Since then I have stuck to native Android Development. There are new plugins and toolkits like Flutter(which is relatively new) as well which uses dart, but I never could get the hang of it since I prefer coding in java or even Kotlin. I started making some replacement applications and started using it and spreading to family members and learning about the user experience. Here are some of the issues which developers usually face.
在当今时代,Android主导着智能手机市场。 自从大约19年前开发者可以使用Android以来,现在它已经被认为是古老的东西。 从那时起,它开始向更好的方向发展,从Eclipse开始,然后在2013年逐渐移至Android Studio。它从几百名开发人员开始,如今全球有近1200万开发人员。 数量如此之多的主要原因是,Android Studio使开发变得如此容易,以至于几乎每个人都可以在一个月内学习它并在应用商店中启动应用(虽然您的应用可能不是那么好,但是仍然可以做到)这样才能进入世界。这就是我进来的原因。我之所以开始使用Android,是因为我对应用程序如何为世界带来巨大差异的想法感到惊讶。 我已经使用Java进行了很长时间的编码,因此对我来说这是一个相当平稳的过渡。 我首先学习了一些XML(不用担心,这非常简单),然后开发了一些定型的入门应用程序,例如调度程序,计算器等。从那时起,我一直坚持原生的Android开发。 还有一些新的插件和工具包,例如Flutter(相对较新)也使用dart,但由于我更喜欢使用Java甚至Kotlin进行编码,所以我从不了解它。 我开始制作一些替换应用程序,并开始使用它,并传播给家庭成员并了解用户体验。 这是开发人员通常面临的一些问题。
1. NullPointerExceptions的奇怪情况 (1. The curious case of NullPointerExceptions)
Being a native Android Developer I knew what I was getting into. And, well there was one such thing that I hated and I am sure it’s the case with most of the java devs and that is NullPointerExceptions. It was something that I knew how to handle but even then it’s something so frustrating that many newcomers just give up, it just haunts you everywhere like a ghost.
作为一名本地Android开发人员,我知道自己正在从事什么。 而且,有一件我讨厌的事情,我敢肯定大多数Java开发人员都是这种情况,那就是NullPointerExceptions 。 这是我知道如何处理的东西,但即使那样,它还是令人沮丧,以至于许多新来者都放弃了,它像鬼一样困扰着您。
NullPointerExceptions occur during runtime. A special null value can be assigned to an object’s reference and denotes that the object is currently pointing to an unknown piece of data and when you try to access this data it throws a NullPointerException. Some areas where this error can occur are when you are trying to compare strings with literals or putting null arguments in methods, etc. In layman terms, the app is just trying to access or perform operations on something that doesn’t have a value. It’s something that java devs have hated since the beginning but know it can’t be done away with since null has a special value in java. So don’t give up if you have just started and are frustrated.
NullPointerExceptions在运行时发生。 可以为对象的引用分配一个特殊的null值,该值表示该对象当前指向未知数据,并且当您尝试访问此数据时,它将引发NullPointerException。 当您尝试将字符串与文字进行比较或在方法中放置空参数时,可能会发生此错误。用外行术语来说,应用程序只是试图访问或执行没有值的操作。 从一开始,Java开发人员就讨厌这件事,但是知道null无法消除,因为null在Java中具有特殊的值。 因此,如果您刚开始感到沮丧,就不要放弃。
A simple way to overcome it is to ensure that all your objects are initialized properly before you use them. Notice that, when you declare a reference variable, you are creating a pointer to an object. You must verify that the pointer is not null before you request the method or a field from the object. Another useful thing about Android Studio is that it has a tool called debugger that can help you in marking locations where the error occurs and stops the execution there. Using a try-catch block is helpful too. These are errors that can be prevented easily by being a little more cautious while dealing with object referencing, method calls, etc. Remember the more errors you get the more you learn.
解决该问题的一种简单方法是,在使用所有对象之前,请确保它们已正确初始化。 请注意,在声明引用变量时,您正在创建一个指向对象的指针。 从对象请求方法或字段之前,必须验证指针不为null。 Android Studio的另一个有用之处是它具有一个称为调试器的工具,该工具可帮助您标记发生错误的位置并在该位置停止执行。 使用try-catch块也很有帮助。 这些错误可以通过在处理对象引用,方法调用等时更加谨慎来轻松避免。请记住,获得的错误越多,您所学的越多。
“Mistakes are a fact of life. It is the response to error that counts.”
错误是生活中的事实。 对错误的响应才是最重要的。”
2.没有标准的用户界面 (2. No standard User Interface)
The next thing which is tedious and time-consuming is making your application responsive to various types of user interfaces. Since Android OS, as well as the UI, can be customized as per the needs of the manufacturer. It becomes cumbersome to make an application responsive because of the varying UIs, this makes it difficult for developers to make apps compatible with each device. The developers have to explore various ways through which they can make the app adaptive and responsive.
繁琐又费时的下一件事是使您的应用程序响应各种类型的用户界面。 由于可以根据制造商的需求自定义Android OS和UI。 由于UI的变化,使应用程序响应变得很麻烦,这使开发人员难以使应用程序与每个设备兼容。 开发人员必须探索各种方法来使应用程序具有自适应性和响应性。
This is a major problem for me since I am a UI designer too. So I had to make so many design changes and then implement them again and again in my app. My take on this problem was to get into the design guidelines set by Google. Material Design is an adaptable system made with concern to varying UI’s available in the market. It is a visual language that synthesizes the classic principles of good design with the innovation of technology and science. Following these guidelines helps a lot while making the UI of an application responsive. The other thing is to use better layout while designing like Relative positioning, constraint, or coordinator layouts since they can help you set guidelines and behavior of your app depending on the User Interface.
这对我来说是个主要问题,因为我也是UI设计师。 因此,我必须进行很多设计更改,然后在我的应用程序中一次又一次地实现它们。 我对这个问题的看法是进入Google制定的设计准则。 材料设计是一个适应性强的系统,考虑到市场上可用的UI的变化。 这是一种视觉语言,将优良设计的经典原理与技术和科学创新相结合。 遵循这些准则有助于使应用程序的UI响应Swift。 另一件事是在设计相对位置,约束或协调器布局时使用更好的布局,因为它们可以帮助您根据用户界面设置应用程序的准则和行为。
“Design is intelligence made visible.”
“设计使智能可见。”
3.作为救主的意图 (3. Intents as Saviours)
Developing in Android can be cumbersome, one of the issues which new developers face is writing long bits of code for simple operations. In some cases there is no way out, you have to write code since there is no substitute. But Android provides us with so many libraries, features, and the ability to intent that sometimes we just need to access them to perform a task. For example, you are making an app wherein you need to share a download link to some images via SMS. One way is to write the code to send SMS and take permission from users to send SMS. The other and a more convenient way is to just intent the user to an app designed for sending SMS and send the link along with it. This not only saves time but your app is less burdened as well.
在Android中进行开发可能很麻烦,新开发人员面临的问题之一是为简单操作编写大量代码。 在某些情况下,没有出路,您必须编写代码,因为没有替代品。 但是Android为我们提供了如此众多的库,功能和意图功能 ,有时我们只需要访问它们即可执行任务。 例如,您正在制作一个应用,其中您需要通过SMS共享一些图像的下载链接。 一种方法是编写代码以发送SMS,并获得用户的许可以发送SMS。 另一种更方便的方法是仅使用户使用专门设计用于发送SMS的应用程序,并随其一起发送链接。 这不仅节省时间,而且您的应用程序负担也减轻了。
Unless there is a good reason to make a custom implementation (ex., a camera app that applies filters), always use Intents for these scenarios. It will save you a lot of programming time, and strip the AndroidManfiest.xml off unnecessary permissions.
除非有充分的理由进行自定义实现(例如,应用滤镜的相机应用),否则请始终在这些情况下使用Intent。 这将节省您大量的编程时间,并去除不必要的权限上的AndroidManfiest.xml 。
You find your heroes where you never look.
您会找到从未见过的英雄。
4.不使用片段 (4. Not using Fragments)
One of the best things I came across while learning to code is Fragments. Fragments are separate building blocks with their own life cycles that exist inside an Activity. An activity can have several fragments attached to them. Though they have a complex architecture and implementation. But once you get the hang of it it’s super easy to use and implement. Not only this but it even reduces the number of activity switches in your app as well since launching separate activity for each app screen is inefficient, since the system will try to keep them in memory as long as it can. Killing one won’t free the resources used by the others. So my take is to learn about fragments and their implementation and once you get the hang of it to use it in cases where unnecessary calls are happening.
片段是我学习编码时遇到的最好的事情之一。 片段是活动内部存在的具有各自生命周期的单独构建块。 一个活动可以有几个附加的片段。 尽管它们具有复杂的体系结构和实现。 但是,一旦掌握了它,它就会非常易于使用和实施。 这不仅而且还减少了应用程序中活动切换的次数,因为为每个应用程序屏幕启动单独的活动效率低下,因为系统将尝试将它们尽可能长时间地保留在内存中。 杀死一个人不会释放其他人使用的资源。 因此,我的目的是了解片段及其实现,一旦掌握了这些片段,可以在发生不必要的调用的情况下使用它。
5.了解位图的功能 (5. Learn the capabilities of Bitmaps)
User’s love content which is well-formatted and nicely displayed. Images, for instance, are extremely nice content, the reason for this is their property of conveying a thousand words per image. They also consume a lot of memory. A lot of memories! Before an image is displayed, it needs to be loaded in the memory and that can take a lot of time if done incorrectly. Loading bitmaps on the UI thread can degrade your app’s performance, causing slow responsiveness or even ANR messages. It is therefore important to manage threading appropriately when working with bitmaps. The total memory needed by an image object is given by 4*image_width*image_height. An efficient way to do this is by using bitmaps. If we try to store an image of resolution 3kx4k the total size will be 48MB.
用户的爱情内容,格式正确且显示得很好。 例如,图像是非常好的内容,这是因为它们的属性是每个图像传达一千个单词。 它们还占用大量内存。 很多回忆! 在显示图像之前,需要将其加载到内存中,如果处理不正确,可能会花费大量时间。 在UI线程上加载位图可能会降低应用程序的性能,从而导致响应速度变慢甚至ANR消息。 因此,在使用位图时,适当地管理线程很重要。 图像对象所需的总内存由4 * image_width * image_height给出 。 一种有效的方法是使用位图。 如果我们尝试存储分辨率为3kx4k的图像,则总大小为48MB。
48 megabytes of your RAM just for a single image!? That’s a lot!
仅用于单个图像的48 MB RAM! 好多啊!
In most cases, I would recommend using the Glide library to fetch, decode, and display bitmaps in your app. It removes out most of the complexity in handling these and other tasks related to working with bitmaps and other images on Android. You can even load the image from a database as well which would make the app lighter and faster.
在大多数情况下,我建议您使用滑行 库以获取,解码和显示应用程序中的位图。 它消除了处理与Android上使用位图和其他图像有关的这些和其他任务的大部分复杂性。 您甚至还可以从数据库加载图像,这将使应用程序更轻,更快。
6.不要重新发明轮子 (6. Don’t reinvent the wheel)
Lastly, A common mistake that many developers commit is to write code for everything on their own. Like making a background thread to handle stuff with your code.
最后,许多开发人员普遍犯的一个错误是自己为所有内容编写代码。 就像制作后台线程来处理代码中的内容一样。
My only advice is NO! Please don’t do that! Network handling, image loading, database connection are some things that most apps have. An effective way to handle all these is not by writing your code but by using pre-created libraries. Some examples of these are using g Picasso for image loading, Gson/Json for image parsing, and using common implementations for social logins. Firebase even comes with a pre-created UI and social authentication which can be implemented just by implementing that library. If you need something implemented, chances are it’s already written, tested, and used widely. Do some basic research and read some Android programming tutorials before writing your code!
我唯一的建议是不! 请不要那样做! 网络处理,图像加载,数据库连接是大多数应用程序具有的功能。 处理所有这些问题的有效方法不是通过编写代码,而是使用预先创建的库。 这些示例包括使用g Picasso加载图像,使用Gson / Json进行图像解析,以及使用常见的实现方式进行社交登录。 Firebase甚至带有预先创建的UI和社交身份验证,可以仅通过实现该库来实现。 如果您需要实施某些东西,则很有可能已经编写,测试并广泛使用了它。 在编写代码之前,请做一些基础研究并阅读一些Android编程教程 !
This Is The Fight Of Our Lives. We Are Going To Win. Whatever It Takes.
这是我们生活的斗争。 我们要赢。 不管付出什么代价。
最后 (Finally)
Android is a powerful platform that is evolving quickly. And the Android developers must keep up with the pace. Knowing that Android is not just on our phones or tablets is even more important. It’s on our wrists, in our living rooms, in our kitchens, and our automobiles. Getting the basics right is of utmost importance before we start expanding. Remember to not stop even if you face a 100 errors in a day. Make more mistakes and learn more from them.
Android是一个功能强大且发展Swift的平台。 Android开发人员必须跟上步伐。 更重要的是,知道Android不仅适用于我们的手机或平板电脑。 它在我们的手腕,客厅,厨房和汽车中。 在开始扩展之前,正确掌握基础知识至关重要。 记住即使一天中遇到100个错误,也不要停止。 犯更多错误,并从错误中学习更多。
“It does not matter how slowly you go so long as you do not stop.”
“你走的慢不要紧,只要你不停下来。”
__________
__________
您面临哪些问题? (What are some of the issues you faced?)
What’s your journey as a developer? Connect with me and I would love to talk about your take on Twitter LinkedIn or Behance!
作为开发人员,您的旅程如何? 与我联系,我很想谈谈您对 Twitter 的看法 LinkedIn 或 Behance !
android 一起关闭