First, how to control the Android led and so on? (Set some parameters for Notificationmanager) The code is as follows:
int id_led=19871103; Notificationmanager nm=(Notificationmanager) Getsystemservice (notification_service); new// Here is the color, we can try to change, theoretically 0xff0000 is red, 0x00ff00 is green notification.ledonms =N; notification.ledoffms =N; notification.flags =
How do I get the apk file installation time? Many Android developers want to design an APK manager, get the APK file installation date Many netizens are not very clear. The method used in early Android123 is to return a applicationinfo array through the Getinstalledapplications method of the Packagemanager class. The SourceDir in the ApplicationInfo class can get the file path of the APK, which is implemented by using the file class to read the last modified time of the files. But this can cause: 1. The original creation time could not be obtained, it may have been created very early, and then replaced. 2. If the APK is in a private location, such as app-Private directory, applications purchased using the market at this location, if no root Android phone is not authorized to read, also causes the acquisition time to fail. On Android 2.3API Level 9, the ApplicationInfo class new Firstinstalltime and LastUpdateTime these two fields, you can directly get to the APK creation or last modified time, even the paid software can be obtained normally. How do I differentiate units px and DP and SP? PX (pixels) pixels--Generally we HVGA represent 320x480 pixels, this is used more. Dip or DP (device independent pixels) devices independent pixels--This is related to device hardware, generally we recommend this to support WVGA, HVGA, and QVGA CWJ, and do not rely on pixels. SP (Scaled Pixels-bestFor text size) enlarge pixels--Mainly handles the size of the font. The following are not commonly used, we also know here android123 is not too much to repeat.In (inches) inch mm (millimeters) mm PT (points) point two, how to dynamically change the ImageView size? Many users may find that the absolute size of the ImageView is defined in the Layout.xml file and cannot be changed dynamically after the size display, in fact, the Android platform in the design of UI controls to take this issue, In order to adapt to different drawable, it is possible to add android:scaletype= "Fitxy" in the relevant imageview of XML , but the use of scaling may cause the current UI to deform. The premise of use is to restrict the layer where the ImageView is located, and you can limit the display using an inline method. Third, how to play the most simple GIF animation in Android? the principle of GIF animation is to play frames by frame, in Android provides the Animationdrawable class can be achieved, some users have written gif89a decoding method in the past J2ME platform transplant to the Android platform can also use, in fact, Google Android above the current 2.2 firmware support methods in addition to Flash Player, the better way to do this is to use the Universal WebKit Browser, we directly in the project embedded in a webview,html as long as the write-like img src= "http ://android123.com.cn/cwj.gif "This is OK, of course, the path can be changed to local, for the browser using the local resource URL is file:/// start. However, webview resource consumption is not small, open a WebView object may occupy at least 8MB of RAM, conservative estimates, of course, more depends on the plug-in and the complexity of the HTML decision.
Iv. how to determine whether a mobile phone has a network or not?
Connectivitymanager Cwjmanager = (Connectivitymanager) Getsystemservice (context.connectivity_service); null) { if (Cwjmanager.getactivenetworkinfo (). IsAvailable ()) {String type = Cwjmanager.getactivenetworkinfo (). Gettypename (); System.out.println ("_____________________-" + type);}; }Else {System.out.println ("_____________________-" +
If you want to develop a network application program, first of all to consider whether to access the network, in the Android phone to determine whether the Internet can be determined by the Connectivitymanager class IsAvailable () method, first obtain the network communication class instance, using Cwjmanager.getactivenetworkinfo (). isavailable (); To return is valid, if True indicates that the current Android phone is connected to the Internet, may be WiFi or GPRS, HSDPA, and so on, the specific can be through the Connectivitymanager class of Getactivenetworkinfo () method to determine the detailed access method, it should be noted that the call needs to join <uses-permission android:name= "Android.permission.ACCESS_NETWORK_STATE" ></ Uses-permission> this permission, on the real machine market and the browser program all use this method, to determine whether to continue, while some network timeouts can also check if the network connection exists, so as not to waste the power resources on the phone.
Five, drawable-hdpi, drawable-mdpi, drawable-ldpi difference: In the previous version, there is only one drawable, and the 2.1 version has drawable-mdpi, drawable-ldpi, drawable-hdpi Three, these three are mainly to support multi-resolution. (1) drawable-hdpi contains high-resolution images, such as WVGA (480x800), FWVGA (480x854) (2) drawable-mdpi, which contains medium-resolution images such as HVGA (320x480) (3 DRAWABLE-LDPI contains low-resolution images, such as QVGA (240x320)
Android Tips (ii)