Android implement countdown button effect

Android implement countdown button effect

Android mobile butler software usually pops up such pop-up boxes when managing the application rights of mobile phones. Such a button appears on many occasions, the system will give a certain time such as 30s prompt the user to select the operation "prohibited" or "allowed", and set the countdown, and after the countdown to zero the system will select the default behavior for the user to perform.This design is very intelligent and automated when no one is using the phone.Here are the effects of using a handler and a Runnable to implement such a button: Android implement countdown button effect In an extremely reprinted article entitled "Several Ways for Android to Use Threads to Update UI", we mentioned the use of Runnable and Handler.PostDelayed (Runnable, Time) to update the interface in Android.The following is a button that implements countdown effects using Runnable and Handler.PostDelayed(Runnable,Time). Assume that the action of clicking the countdown button is the running function function(), and the button variable name is forbiddenBtn. The following is the implemented code: principle The above code implementation principle is to use the timeHander.postDelayed(context, int) function to periodically call a Runnable, here is a time delay 1000ms execute the timerRunnable.The code that

Android uses threads to update the UI in several ways

Android uses threads to update the UI in several ways

Algorithm language Software development 5 years ago (2015-08-18) Views: 16 Comments: 0

Method one: (java habits, not recommended for use in android) Just started to contact the android thread programming, the habit is like java, trying to solve the problem with the following code Can realize the function, refresh UI interface.However, this is not possible because it violates the single-threaded model: Android UI operations are not thread-safe and these operations must be performed in the UI thread. Method two: (Thread+Handler) After consulting the documentation and apidemo, I discovered that the common method is to use Handler to implement UI thread updates. The Handler handles UI updates based on received messages.The Thread thread issues a Handler message to notify the UI of the update.   Method 3: (java habits, not recommended) In the Android platform, you need to perform the cycle-by-cycle method. You can use the TimerTask class that comes with Java. The TimerTask consumes less resources than the Thread. In addition to using the Timer that is provided by Android, the Timer timer is better. Solution. We need to import import java.util.Timer; and import java.util.TimerTask;   Method 4: (TimerTask + Handler) In fact, this is not enough. This is related to Android's thread safety!Should achieve timer function through Handler!   Method 5:

BY request note description and feedback page

BY request note description and feedback page

Android works 5 years ago (2015-06-21) Views: 12 Comments: 0

First, software introduction This software is an Android user's big job: BY leave article means to provide students with basic functions such as leave request, counselor's leave, teacher confirmation, notification push, email notification and password reset. Interactive features such as live chat and chat (time is limited, this feature is not implemented). Second, software function introduction 1. Connected to the virtual host to achieve network login function, and remember the password and other details; 2. Use database management BY leave articles, course information, class information, leave records, class selection records; 3. Passing data in the form of a JSON packet: The server queries the database for the PHP language and the client resolves to the Android java language. 4. Two ways to deal with leave request: the counselor can use the Android client or click on the link in the email to directly approve and reject the student's leave request through the browser GET method; 5. Implementation of email reminder notification: Use the email address of leavepaper@wangbaiyuan.cn, when the student has a new leave request, counselor approval or refusal to take leave, notify the relevant personnel in a timely manner; 6. Sharing function: BY leave request for you to automatically

Detailed AndroidFragment life cycle

Detailed AndroidFragment life cycle

Hundred Encyclopedias Software development 5 years ago (2015-06-15) Views: 8 Comments: 0

1 two charts of life cycle Fragment life cycle diagram:   Fragment and Activity life cycle comparison chart: 2 Life cycle analysis 1. When a fragment is created, it goes through the following states. onAttach() onCreate() onCreateView() onActivityCreated() 2. When this fragment is visible to the user, it goes through the following states. onStart() onResume() 3. When this fragment enters "background mode", it will experience the following state. onPause() onStop() 4. When this fragment is destroyed (or the activity holding it is destroyed), it will experience the following state. onPause() onStop() onDestroyView() onDestroy() // originally missed this callback, thanks to xiangxue336. onDetach() 5. Just like activitie, in the following state, you can use the Bundle object to save a fragment of the object. onCreate() onCreateView() onActivityCreated() 6. Most of the states of the fragments are similar to activitie, but the fragment has some new states. onAttached() - called when the fragment is added to the activity (in this method you can get the activity). onCreateView() - This method is called when the activity wants the layout of the fragment. Fragment creates its own layout in it. onActivityCreated() - This method is called after the activity's onCreated() method returns onDestroyView() -

Android development using FontAwesome icon font

Android development using FontAwesome icon font

Front end and interface Software development 5 years ago (2015-06-11) Views: 10 Comments: 0

English original reference: https://github.com/liltof/font-awsome-for-android In a previous article, I introduced to you in the WEB front end using FontAwesome fonts. Font-Awesome is an icon collection font designed for Bootstrap, which contains more than 300 commonly used icons.Using Font-Awesome also has the following advantages: 1. Reduced drawing of icons 2. Can set the color and size of the icon 3. Reduce the size of the icon and reduce the size of the apk. Only one icon font file is required. There are no icon files of various sizes, such as HDPI, XHDPI, and other icon sizes. Android development using FontAwesome icon font Go to the Font-Awesome homepage and download the Font-Awesome font (fontawesome-webfont.ttf) file and place it under the project's assets directory. Find the string corresponding to the icon you want to use (font-awsome-for-android contains an icon and The corresponding file of the string, the latest correspondence is found in the font-awesome.css file in the css directory of the downloaded Font-Awesome font), the desired icon text is set in the TextView, and then the TextView font is set to Font-Awesome font defined.   Xml layout file code   Java code In addition, if you need to use the Font-Awesome icon in

Improve fluency Google push new Android development language Sky

Improve fluency Google push new Android development language Sky

Software development 5 years ago (2015-05-04) Views: 16 Comments: 0

Transfers from Zhongguancun Online Author: Zhang Jinliang | Editor: Weijing Fang     According to foreign media reports, at the recent Dart Developer Summit, Google officially displayed Android's latest development language, Sky.It is reported that Sky is essentially Google's own web development language Dart. Google said that Sky is only an open source trial.However, compared to the traditional Android application development method, Sky has many advantages.The main purpose of Sky is to increase the speed and response speed.On most devices, the application of smooth standards is to achieve 60FPS frame rate.However, the Dart team wants to achieve a frame rate of up to 120 FPS.Currently on the Android platform, many applications can hardly achieve the standard 60 FPS frame rate, let alone 120 FPS. The Dart team demonstrated a demo application that draws only 1.2 milliseconds per frame.Although this is just a simple demonstration, it means that Sky has a lot of space for developing smooth and complex applications, which also makes the frame rate of 120FPS possible.The team stated that Sky's application program interface (API) does not affect the main thread of the interface, which means that even if the application runs slower, the user interface will maintain a smooth response.

Android Virtual Machine Acceleration – Intel HAXM Accelerates the Real Machine

Android Virtual Machine Acceleration – Intel HAXM Accelerates the Real Machine

Software development 5 years ago (2015-05-04) Views: 18 Comments: 0

Quote: Android virtual machine is inherently slow? The speed of the Android virtual machine has always been known as slow. Frequent Caton's Android virtual machine is a very painful thing for developers, which greatly affects the developer's efficiency and mood.Now I would like to introduce a way to speed up the Android virtual machine. If your computer has an Intel CPU supporting Intel(R) Virtualization Technology (VT) (you can use VT technology, if you are an i5 or higher intel CPU , generally have this technology, if it is AMD's CPU should not be able to enjoy the following "welfare"), you may wish to try it, very guests since the use of Android virtual machine acceleration, run, debug the application of the speed to achieve true Speed. First, download the CPU/aBI for the intel atom Android system image Certainly taking into account compatibility issues and other reasons unknown to most guests, the off-the-shelf Android virtual machine downloaded from the Internet is often "armeabi-v7a", and the CPU system image of this architecture is not hardware of Intel(R) Virtualization Technology (VT). Acceleration, which is the reason for the slowness of the Android virtual machine card, may be the same as previous thoughts of

Android resource details (primary)

Android resource details (primary)

Software development 5 years ago (2015-05-01) Views: 6 Comments: 0

First, Android resource classification explain   1, Android resource classification The resources in Android are divided into two categories: resources that can be directly accessed, and native resources that cannot be accessed directly; -- direct access to resources: These resources can be accessed using R. They are all stored in the res directory. When compiling, The R.java resource index file will be automatically generated; -- Native resources: These resources are stored under assets, they cannot be accessed using R class, and can only be read as binary streams via the AssetManager. 2, Android resources explain   Resource details under the res directory: -- res/animator : The property animation of the XML file directory. The property animation is the animation that defines the start, finish, repeat time and other parameters; --res/anim : The tween file's XML file directory. Tweening animation defines only the starting and ending frames. The middle action is calculated by the system to obtain the action process. --res/color : list of XML files in the color list; -- res/drawable : Stores the real bitmap file. It can also store XML files of Drawable objects and subclass objects. --res/layout : interface layout file directory; -- res/menu : The menu

Relying on Web Hosting to Provide Software Update Service for Homemade APPs (1)

Relying on Web Hosting to Provide Software Update Service for Homemade APPs (1)

Software development 5 years ago (2015-04-21) Views: 8 Comments: 0

After learning one month of Android, I wrote a few small programs and I always felt that something was missing.Seeing that the software on the general market provides software update services, most guests want to have a virtual host. Can they build a software update server by themselves?Baidu took a look at “relying on virtual hosts to provide software update services for self-made APPs.” Unfortunately, searching for Baidu has not found a solution yet. To implement software updates, there must be a comparison between the latest software version number published on the server and the version currently used on the client.If the version number is the same, the user is prompted to "currently the latest version"; if the latest version published on the server is higher than the one used by the user, the "version update" is prompted and the download function is provided, and the installation is automatically performed after the download is completed.To get the latest version number, you must read the database. If you directly connect the database directly with the user's password, this is undoubtedly insecure, because if you decompile or crack your software, your database will be desperate.So, the solution I came up with was

Eclipse Android use activity template to quickly create a new activity

Eclipse Android use activity template to quickly create a new activity

Software development 5 years ago (2015-04-14) Views: 14 Comments: 0

Android developers using android studio may find it is similar to eclipse + ADT, personal android studio after found that android studio in addition to the interface is more cool outside, there is not much advantage. And the majority of users criticized the memory usage is also a big problem There is no solution: I found that android studio is more memory than eclipse when developing Android. However, android studio in the file - new menu, you can quickly create a new Activity function is quite practical, as shown in Figure: android studio's new activity function do not have to let us very troublesome to build a java class and then inherit the Activity, Activity Several necessary methods are automatically declared for us. In fact, eclipse also has this feature: Eclipse Android use activity template to quickly create a new activity Eclipse new menu inside actually has a quick new Activity function, but not on the eye-catching position: rapid new activity several methods: 1 respectively open the menu FILE - NEW - other - Android - Activity; 2Ctrl + N- - Android - Activity; can also use the new activity method can quickly create new Android image resource file

登录

Forget password?

您也可以使用第三方帐号快捷登录

切换登录

注册

TW