Class java.lang.Object
public class Object
Class Object is the root of the class hierarchy. Every class has Object as a superclass. All objects, including
arrays, implement the methods of this class.
Methods-
clone()
|
Creates a new object of the same class as this object.
|
equals(Object)
|
Compares two Objects for equality.
|
finalize()
|
Called by the garbage collector on an object when garbage collection determines that there
are no more references to the object.
|
getClass()
|
Returns the runtime class of an object.
|
hashCode()
|
Returns a hash code value for the object.
|
notify()
|
Wakes up a single thread that is waiting on this object's monitor.
|
Wakes up all threads that are waiting on this object's monitor.
| |
toString()
|
Returns a string representation of the object.
|
wait()
|
Waits to be notified by another thread of a change in this object.
|
wait(long)
|
Waits to be notified by another thread of a change in this object.
|
wait(long, int)
|
Waits to be notified by another thread of a change in this object.
|
onCreate()
Called when the activity is first created. This is where you should do all of your normal static setup: create
views, bind data to lists, etc. This method also provides you with a Bundle containing the activity's previously
frozen state, if there was one. Always followed by onStart().
onStart()
Called when the activity is becoming visible to the user. Followed by onResume() if the activity comes to the
foreground, or onStop() if it becomes hidden.
XML Parsing
Android provides three types of XML parsers which are DOM,SAX and XMLPullParser. Among all of them
android recommend XMLPullParser because it is efficient and easy to use. So we are going to use
XMLPullParser for parsing XML.
SAX
Android provides the facility to parse the xml file using SAX, DOM etc. parsers. The SAX parser cannot be
used to create the XML file, It can be used to parse the xml file only. It consumes less memory than DOM.
DOM
Advantage- It can be used to create and parse the xml file both but SAX parser can only be used to parse the
xml file.
Disadvantage- It consumes more memory than SAX.
XML PullParser
Android recommends to use XMLPullParser to parse the xml file than SAX and DOM because it is fast.
The org.xmlpull.v1.XmlPullParser interface provides the functionality to parse the XML document using
XMLPullParser.
Events of XmlPullParser
The next() method of XMLPullParser moves the cursor pointer to the next event. Generally, we use four
constants (works as the event) defined in the XMLPullParser interface.
START_TAG :An XML start tag was read.
TEXT :Text content was read; the text content can be retrieved using the getText() method.
END_TAG : An end tag was read.
END_DOCUMENT :No more events are available
Common Exception in Android
OutOfMemoryError
This error can happen at runtime when you ask Dalvik to allocate a large amount of memory on the heap – for
instance when trying to add a large bitmap into a container like an ImageView. If you’re pulling the bitmap
from a remote endpoint you need to be sure you’re guarding against files, as these might cause the app to crash
if this exception isn’t handled. There are configuration flags available such as android:largeHeap in the
AndroidManifest if you do need to allocated large objects.
Comments
Post a Comment