Unique identification code This is useful in Web applications, such as checking for duplicate registrations.Import Android.provider.Settings.Secure;Private String android_id = secure.getstring (GetContext (). Getcontentresolver (), secure.android_id);We will use the unique identification code of the device more or less in the course of the project, we hope to get a stable and reliable device unique identification code. Today we will cover several ways
Android network programming is divided into two types: HTTP protocol based, and socket based. HTTP protocol based : HttpClient, HttpURLConnection, asynchttpclient framework, etc. Based on the socket : (1) socket, ServerSocket for TCP/IP (2) for UDP/IP Datagramsocket, Datagrampackage (3) Apache mina framework One, httpurlconnection implementation
String response = null;
URL url = new URL (path); HttpURLConnection connection = (htt
On the exit of all activity, the current online more popular way about the following:① the way of using Activitymanager;② a way to customize an activity collection class;③ by means of sending broadcasts;④ by killing the current application process;The specific implementation of the above can be self-Google Baidu, here no longer repeat.But these methods are either
On the exit of all activity, the current online more popular way about the following:① the way of using Activitymanager;② a way to customize an activity collection class;③ by means of sending broadcasts;④ by killing the current application process;The specific implementation of the above can be self-Google Baidu, here no longer repeat.But these methods are either
header and the cookie header.The Set-cookie header is contained in the response header (Responseheader) of the Web serverThe cookie header is contained in the browser client request header (Reguestheader)The operation of the cookie, the specific analysis is as follows2. Simple and brutal way to persist cookiesThe method is derived from this http://tsuharesu.com/handling-cookies-with-okhttp/After seeing how the cookie is transmitted, we can persist th
APK is actually the zip format, so, after extracting the APK, you will see there is a meta-inf directory. idea: because the Meta-inf directory does not affect the APK signature and run, so we can add an empty file in the Meta-inf directory, different channels to add different empty files, filenames represent different channels. In Android engineering, Java code reads this convention in Meta-inf with the file name that begins with Mtchannel_.The second
English Original: Probably is the best (?) to Save/restore Android Fragment ' sKey points: Fragment's arguments.After years of using fragment, I want to say that fragment is really a smart design, but there are too many problems to be solved by using fragment, especially when dealing with data retention.First, although it has an activity-like onsaveinstancestate, don't think you can keep the data just by Onsaveinstancestate.Here are some examples:Scen
(index); Is the data that gets the specified subscript index to int type; int id = cursor.getint (cursor.getcolumnindex ("id")) ; String named = cursor.getstring (Cursor.getcolumnindex ("name")); String number = cursor.getstring (Cursor.getcolumnindex ("number"));//Instantiate query result data Object person = new person (ID, named, number);} Close the database connection, release the Resource Db.close ();//Return the data result object return person; /** * Update a data based on name * * @para
Guy:The UI event queue processes events sequentially. After Setcontentview () is called, the event queue contains a messagethat requires re-layout, so anything you post to the queue will be executed after the layout has changed. Your code executes only once, and you don't have to disable observer after each execution, and it's much more hassle-free.OnLayout method of Rewriting view:view = new View (this) { @Override protected void OnLayout (Boolean changed, int l, int t, int r, int b) {
Setnegativebutton () method to add a button, because the method (Simpledialog ()) Here only provides the call, so there is no specific function to implement the button, you can override the two methods in the actual call to achieve the specific functionality.
The invocation is as follows, and the dialog boxes for several other ways are basically the same as the way this method is invoked, and the following are no longer given.
public void On
There are two ways of submitting data to the server, post and get. The difference between the two is mainly three points, security, length limit, data structure. Where GET request security is relatively poor, the data length is limited by the browser address bar and no method body is used. Both are more important ways of submitting data. Here is a brief introduction to three types of post and
First, the phenomenon
The usual way to download files via the Android WebView is
1. Rewrite the Downloadlistener Ondownloadstart method, pop-up dialog box in Ondownloadstart method prompts the user to have a new file to download
2. After the user clicks OK, downloads the file through the HTTP GET
As a result of the Androi
When I first started using Android studio, when creating a javabean, I used to right-click on the JavaBean class to find the option to generate Get,set. But unfortunately, I can't find it.That way. How to quickly set,get or generate constructors to generate the ToString method.There are two ways of doing this:Way One:
action = Intent.getaction (); // When the system starts scanning the SD card, you can add a wait box for the user experience if (Intent.action_media_scanner_ Started.equals (action) {} // When the system scan is complete , stop displaying the wait box and requery contentprovider if ( Intent.ACTION_MEDIA_SCANNER_FINISHED.equals (ACTION)) {}}} In this way, we can force the Media Library to be updated.However, after 4.4,
In Android development, we often use the network connection function and the server data interaction, this Android SDK provides Apache httpclient to facilitate our use of a variety of HTTP services. You can think of httpclient as a browser, through its API we can easily send out Get,post request (of course its function is far more than these)
This only describes
mcontext) { //string imei = ((Telephonymanager) Mcontext.getsystemservice (Mcontext.telephony_service)). Getdeviceid (); String IMEI = secure.getstring (Mcontext.getcontentresolver (), secure.android_id); return imei; }The disadvantage of this approach is that:1. Users who encounter high security alertness, I do not accept this permission, do not install your app.2. Non-mobile device, if only the device with WiFi or music pla
packaged APK file) Common error: Apktool The following information is often present during anti-compilation1.Input file is not found or is not readable.2.Destination directory (C:\Users\user\a) already exists. Use-f switch if you want to overwrite it.3.Exception in thread "main" Brut.androlib.AndrolibException:Could not decode ARS C fil .....Solution:1 and 2 is because the Apktool upgrade to more than 2.0, the use of the way has been replaced by: Apk
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.