Android Development Tips Collection

Source: Internet
Author: User

Activity.startactivities ()--very good for booting from the middle of the app stream.

Textutils.isempty ()--a simple tool class that is universally applicable.

Html.fromhtml ()--a quick way to format HTML, I think it's not very fast, So I don't use it often (I say it's not often used to highlight this sentence: try to build spannable manually to replace html.fromhtml), but it's good for rendering text that gets from the Web.

Textview.seterror ()--The user experience is good when validating user input.

build.version_codes--it not only describes the version number, but also summarizes the different features of each Android version.

Log.getstacktracestring ()--Convenient logging tools.

Layoutinflater.from ()--simple tool to simplify a series of lengthy getsystemservice () calls.

Viewconfiguration.getscaledtouchslop ()--use the values provided in viewconfiguration to ensure that all touch interactions are uniform.

phonenumberutils.convertkeypadletterstodigits--makes it easier to process phone numbers, and many people only provide letters, not numbers.

Context.getcachedir ()--using the system-provided cache directory for data caching is very simple but many people don't know how to use it.

argbevaluators--handles the color gradient. As Chris Banes says, this class does a lot of auto-boxing, so it's best to get rid of its logic and implement it yourself.

contextthemewrapper--makes it easy to change the subject during operation.

space--lightweight view components, which can skip the drawing process, are great for any scene that requires placeholders.

Valueanimator.reverse ()--can be smooth to cancel the animation effect, great.

Dateutils.formatdatetime ()--Provides a one-stop service for locale-formatted time/date strings.

alarmmanager.setinexactrepeating--saves power by using an alarm grouping, even if you call only one alarm instance, it's still good (make sure that Alarmmanager.cancel () is called automatically when you're done.

Formatter.formatfilesize ()--a regional file size formatting tool.

Actionbar.hide ()/. Show ()--can be animated when ActionBar is displayed or hidden. It can be more elegant when switching to fullscreen.

Linkify.addlinks ()--You can control the addition of links on text.

staticlayout--is useful when rendering text in a custom view.

Activity.onbackpressed ()--easy to control the return button, you can use when you need to customize the return key operation.

gesturedetector--can listen for action events and related listener events (click, scroll, swipe, etc.). It is simpler than implementing some of the action events of your system.

drawfilter--lets you manipulate the canvas even if the draw method is not called. For example, you can set a drawfilter when creating a custom view to alias all view settings in the parent view.

Activitymanager.getmemoryclass ()--lets you know exactly how much memory your device has left. This is useful when calculating how to set the cache size.

Systemclock.sleep ()-this method is very convenient to ensure a certain amount of time sleep, usually I used to debug and analog network delay.

viewstub--It is an initialization view that doesn't do anything, but can then load a layout file. This is a good place to make placeholders in a slow-load view. The only drawback is that tags aren't supported, so if you're not careful, you might want to include unwanted nesting in the view structure.

displaymetrics.density--This method can get the density of the screen, many times need to remove the system auto-scaling accuracy function, but sometimes in the control of the time is also useful (especially when the custom view).

Pair.create ()--easy way to build classes and constructors.

urlquerysanitizer--Use this tool to make it easy to check URLs.

fragment.setarguments--because it is not possible to add parameters when building a Fragment, this is a good thing to set parameters (even when the configuration changes) before creating the Fragment.

Dialogfragment.setshowsdialog ()--This is a very ingenious way, dialogfragment can be displayed as normal fragment! This allows fragment to take on dual tasks. I usually add oncreateview () and Oncreatedialog () when I create a fragment to create a fragment with a dual purpose.

Fragmentmanager.enabledebuglogging ()--it helps when you need to observe the fragment state.

localbroadcastmanager--This will be safer, simpler and faster than the overall broadcast. The event buses mechanism such as Otto is more useful for your application scenario.

Phonenumberutils.formatnumber ()-As the name implies, this is used when the numbers are formatted.

Region.op ()--I found it useful to compare the area before two renderings, and if you have two paths, how do you know if they overlap? Use this method to do so.

application.registeractivitylifecyclecallbacks--Although the official documentation is missing, I think it is a handy tool for registering the activity's life cycle with some callback methods (as the name implies).

versionnamesuffix--This gradle setting allows you to modify the version Name property in manifest based on different build types, for example, if you need to end with "-snapshot" in the Debug version, Then you can easily see whether the current debug version or release version.

cursorjoiner--If you are using only one database, you can use join in SQL, but Cursorjoiner is useful if you receive data from two independent contentprovider.

genymotion--a very fast Android simulator that I have been using.

-nodpi--in the absence of a special definition, many modifiers (-mdpi,-hdpi,-xdpi, and so on) will automatically scale assets/dimensions by default, and sometimes we need to keep the display consistent, in which case we can use-nodpi.

Broadcastrecevier.setdebugunregister ()--Another convenient debugging tool.

Activity.recreate ()--forces the activity to rebuild.

Packagemanager.checksignatures ()-If you have installed two apps at the same time, you can use this method to check. Without a signature check, other people can easily imitate your app by using the same package name.

Activity.ischangingconfigurations ()-If the configuration changes frequently in the activity, you can use this method without having to manually save the state of the work.

searchrecentsuggestionsprovider--is a quick and easy way to create the provider of the most recent cue effect.

viewtreeobserver--This is a great tool. You can enter into the view and monitor various states of the view structure, which I usually use to do the view measurement (often used in custom views).

org.gradle.daemon=true--This sentence can help reduce the time of gradle build, only when the command line is compiled, because Android studio has already used this.

databaseutils--a usage tool that contains various database operations.

Android:weightsum (linearlayout)-if you want to use layout weights, but do not want to fill the entire linearlayout, you can use WeightSum to define the total weight size.

Android:duplicateparentstate (view)-This method allows the child view to replicate the state of the parent view. For example, if a viewgroup is clickable, you can use this method to change the state of its sub-view when it is clicked.

Android:clipchildren (ViewGroup)--If this property is set to unavailable, then ViewGroup's child view will be drawn out of its range, which is required when animating.

Android:fillviewport (ScrollView)--In this article is a detailed article link, you can solve in ScrollView when the content is not enough to fill the screen when the problem.

Android:tilemode (bitmapdrawable)--You can specify the pattern in which the picture uses a repeating fill.

Android:enterfadeduration/android:exitfadeduration (Drawables)--this property can define the fade effect before it is displayed when the drawable has multiple states.

Android:scaletype (ImageView)--Define how to scale/crop the picture in ImageView, generally use more "Centercrop" and "Centerinside".

<merge>--This tag can include other layout files in another layout file, instead of creating a new viewgroup, which is required for custom viewgroup, you can automatically define its subassemblies by loading a tabbed layout file.

atomicfile--atomically through the use of backup files. I have written this point before, but it is better to have an official version.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.