Private String getappversion () {Packagemanager _packagemanager=getpackagemanager (); try {PackageInfo _packageinfo=_ Packagemanager.getpackageinfo (Getpackagename (), 0);//Can get all the information of the application return _packageinfo.versionname;} catch (Namenotfoundexception e) {//TODO auto-generated catch Blocke.printstacktrace (); return "";}}Google has defined two version attributes for APK :versioncode and versionname, They have different uses. Versioncode: Not visible to consumers, o
Public classLogutil { Public Static Final intVERBOSE = 1; Public Static Final intDEBUG = 2; Public Static Final intINFO = 3; Public Static Final intWARN = 4; Public Static Final intERROR = 5; Public Static Final intnothing = 6; Public Static Final intLevel =VERBOSE; Public Static voidV (string tag, string msg) {if(Level VERBOSE) {LOG.V (tag, msg); } } Public Static voidd (string tag, string msg) {if(Level DEBUG) {LOG.D (tag, msg); } } Public Static voidI (strin
Android Application-Use of Google's official Json parsing tool Gson
1. Gson Introduction
Gson (also known as Google Gson) is an open-source Java Library released by Google. It mainly uses serialized Java objects as JSON strings or deserialized JSON strings as Java objects. That is, the conversion and parsing between Java objects and json strings.
Ii. Usage
Gson applications mainly include toJson and from
Android Network Connection Tool
Public class NetUtil {/*** check the current network */public static boolean checkNet (Context context) {// determine whether the current user's mobile phone uses WIFI to communicate boolean isWIFI = isWIFIConnection (context); // determine whether the current user's mobile phone uses APN to communicate boolean isAPNConnection (context ); // No -- Prompt User -- jump to the n
Android asynchronous task code is very short, simple asynchronous tool encapsulation, easy to execute asynchronous tasks
It is relatively simple. There are three classes.
1. Create a single-instance thread pool to execute asynchronous tasks
package com.ferris.pool;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors;public class FerrisPoolManager {private ExecutorService servic
Android Network File upload and download tool class Summary
1. Get the last modification time of the file
@ SuppressLint ("SimpleDateFormat") public String getFileDataTime (File file) {Date date Date = new Date (file. lastModified (); SimpleDateFormat sdformat = new SimpleDateFormat ("yyyy-MM-dd HH: mm: ss"); // String LgTime = sdformat in 24-hour format. format (date); return LgTime ;}
2. Compare the two
Android image processing toolThe image tool class can be used for Bitmap, byte array, and Drawable conversion and image scaling. Currently, the function is weak and will be enhanced later. For example:BitmapToDrawable (Bitmap B) bimap to drawableDrawableToBitmap (Drawable d) drawable to bitmapDrawableToByte (Drawable d) drawable to byte
ScaleImage (Bitmap org, float scaleWidth, float scaleHeight) Scaling Im
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.