) { //e.printstacktrace (); } catch (IOException e) { e.printstacktrace (); } } }If there is no network foundation, this understanding is still a little complicated, the following posted the project code, we have to experience it, the use of sockets is actually very simple, mainly logic processing.Here are a few things to keep in mind:(1) android2.3 can no longer invoke the network request in the main thread of the UI, will crash directly, so you need to use handler to send message
(RemoteException e) {//TODO auto-generated catch block E.printstacktrace (); }}//Called when the connection with the service disconnects unexpectedly public void Onservi cedisconnected (componentname className) {log.e (TAG, "Service has unexpectedly DisconnecTed "); Miremoteservice = null; } }; protected void OnDestroy () {Super.ondestroy (); Unbindservice (mconnection); }}Use the service, also need to configure in Androidmanifest.xml, add Because the service is fo
Original works can be reprinted. During reprinting, you must mark the original source, author information, and this statement in hyperlink form. Otherwise, legal liability will be held. Http://blog.csdn.net/love254443233/article/details/7898923
In the past, I only learned about Android, but I have not studied it in depth. With almost five years of Java development experience, if you want to quickly learn Android
Android getting started-network communication-HttpURLConnection
There are many ways for Android to communicate with remote servers. Today we will introduce how to use http to obtain data from remote servers.
In android, you can use the following three interfaces to communica
Android basic getting started -- 2.4.15 simple use of DrawerLayout (Official slide menu)This section introduces:
This section introduces the last widget of the basic UI control:DrawerLayout, A slide menu officially provided for usControl, just like ViewPager in the previous section, introduced later than 3.0. To use it in earlier versions, v4 compatibility is r
out!!!Then draw the square:// Draw a square gl.glloadidentity (); Gl.gltranslatef (1.5f0.0f,-6.0f); // gl.glcolor4f (1.0f, 0.0f, 0.0f, 1.0f); Gl.glvertexpointer (3004); Gl.glfinish ();Note that the Color:gl.glColorPointer (4, gl10.gl_float, 0, Mcolorbuffer) have been loaded before the triangle was drawn;If you call Gl.gldisableclientstate (Gl10.gl_color_array) after drawing, you can see that the triangles are flashing and the squares are not visible . This piece is also a misunderstanding! If y
()); getHelper().getRuntimeExceptionBlackDao().create(entity); }}Check:privatequeryBlack() { return getHelper().getRuntimeExceptionBlackDao().queryForAll(); }By deleting:DAO provides a series of delete methods. can refer to the document use, here is a more powerful deletebuilder, it can add the where condition, and the API is the builder mode, nonstop dot point, completely stop ~haha, of course, no, but Deletebuilder, and QueryBuilder, Updatebuilder and so on.priva
Intentions (Intent)Java.lang.Object;Android.content.intend;Android.content.pm.LabeledIntent;Mainly divided into Action Intent and broadcast intent,intent serve Android three core components: Activity, services, broadcast ReceiverHow to handle IntentIntent Start a new Activitypublic void startmainactivity (view view) {finish (); final Intent Intent = new Intent (); Intent.setclass (testactivity.this , Mainactivity.class); startactivity (intent);}Keep i
Android official Getting Started document [13] pausing and resuming an activityPausing and Resuming an ActivityPausing and resuming an activityThis lesson teaches1.Pause Your Activity2.Resume Your ActivityYou should also read? ActivitiesThis lesson teaches you1. Suspend your Activity2. Resume your ActivityYou should also read? Activity activitiesTry it OutGive it
Enter edit mode and enter at the beginning of the current line
A
go to edit mode and enter at the end of the current line
O
Enter edit mode , starting at the next line of the current line
O
Enter edit mode , starting at the top line of the current line
: (colon)
Enter Command mode
W
Save File
Q
Exit the VIM editor
Q!
Force exit from the Vim editor without sav
directory:Finally we see mode_private this parameter, saying is private, I thought the private meaning is: an activity created by the XML can not be shared by other activity, in fact, refers to other application, other applications can not access. In the same application, as long as the name of the sharedpreferences is right, it is from the shared_prfs/directory down to find files, and all the activity can be interoperable.Finally let's take a look at what is generated in the XML file, and I ex
();} return netpicture;}We can see that the processing method is exactly the same as get, just after we get the input stream is, we convert it directly to bitmap.Another way to invoke the call section is to save the captured picture to Local:Save JPG image to local private void savejpgbitmaptolocal (Bitmap Bitmap, String path,string filename) {File File = new file (Path, fil ename); OutputStream os;try {os = new FileOutputStream (file); bitmap.compress (compressformat.jpeg, OS); Os.flush () ; O
Document directory
1. Basic Framework of the project file
Getting started with Android1. After creating an android project, the basic framework of the project file will automatically generate several files. The first is the SRC file, which mainly stores. java files and is the main part of the code. There are also several files worth noting, one of which is
@+id/btn//indicates that a new control index with ID btn is added to the R.java file, the most common way to declare a control ID.@+android:id/list//+android: Indicates reference to Android. R.id inside the ID resource defined, if android.r.id inside does have the title of this ID resource, directly use it, if not, in the current application of the r.id to produce a title identifier@id/btn//indicates a refe
class. For example: Uitable controls, Uitextview controls, Uipickerview controls, and so on.Based on an iOS-developed event-handling approach, there are several ways that Android event processing can be handled in two ways:1. Listener-based event handling: Define the component first, then set the listener for the component.2. Callback-based event handling: Let each component inherit the UI class and override the event-handling method for that class.
mainly composed of three components, Android to these three parts made the following format:
Must start with VND.
If the content URI ends with a path, then android.cursor.dir/, followed by android.cursor.item/if the content URI ends with an ID.
Finally, connect the vnd.
Therefore, for content://com.example.app.provider/table1 this content URI, its corresponding MIME type can be written as: vnd.android.cursor.dir/ Vn
parameter and automatically uses the current application's package name as a prefix to name the sharedpreferences file
Once you get the Sharedpreferences object, you can begin to store data in the Sharedpreferences file, with three main steps:
Call the edit () method of the Sharedpreferences object to get a Sharedpreferences.editor object
Add data to the Sharedpreferences.editor object, such as adding a Boolean type of data using the Putboolean () method, adding a
(Intent);Using implicit intent, you can start activities for other programsPassing data between activitiesPass data down: The parent Activity Intent.putextra (,), the first parameter is the key, and the second parameter is a value.Sub-activity: Intent Intent = Getintent (); Gets the intent that is used to start the activityString str = Intent.getstringextra (); parameter is keyPass data up: Parent activity Startactivityforresult (intent,) the second parameter is a request codeChild activity: Ca
; }} test publicclasstest{ publicstaticvoidmain (String[]args) { jotterjt =newjotter ();powersupplydevice Powersupplydevice=newpowersupplydevice (); Voltageadapteradapter=newmyvoltageadapter (Powersupplydevice); jt.setadapter (adapter); jt.inputvoltage (); }} Execution results Here, let's summarize the advantages and disadvantages of the adapter pattern:Advantages:1, two different interfaces can be linked together, low coupling.2, increase the transparency and reusability of the class,
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.