Here we go!.. two of the Android phones I own. I like the Motorola Milestone for now.
I still see few bugs in the Milestone while turning from landscape to portrait mode.
Here we go!.. two of the Android phones I own. I like the Motorola Milestone for now.
I still see few bugs in the Milestone while turning from landscape to portrait mode.
I was searching for a good tutorial as this is going to be very important feature I am going to experiment in google maps of Android phone. Here I found a beautiful link for the same
http://mobiforge.com/developing/story/using-google-maps-android
Let me go through and quickly do some implementation and shortly I will update with the crisp results.
After a long struggle I found a way to upload an image in a multipart method using POST. For this, it is required to use the apache’s jar file rather than using the Android’s native HTTP apis. This makes the process simple.
Before going to the code, its is required to download the required jar files.
http://www.java2s.com/Code/JavaDownload/PostMethodExample.zip
The above source code bundle has the required jar files in its lib directory. You need to add this in to your android project’s lib directory and use the following code.
static boolean doUploadinBackground(final byte[] imageData) throws Exception{
String responseString = null;
PostMethod method;
method = new PostMethod(Constants.hostAddress+Constants.imgUploader);
org.apache.commons.httpclient.HttpClient client = new org.apache.commons.httpclient.HttpClient();
client.getHttpConnectionManager().getParams().setConnectionTimeout(
100000);
FilePart photo = new FilePart("photoData", new ByteArrayPartSource(
"photoData", imageData));
photo.setContentType("image/jpeg");
photo.setCharSet(null);
String s = new String(imageData);
Part[] parts = {
new StringPart("mobileNo", “12345”),
photo
};
method.setRequestEntity(new MultipartRequestEntity(parts, method
.getParams()));
client.executeMethod(method);
responseString = method.getResponseBodyAsString();
method.releaseConnection();
Log.e("httpPost", "Response status: " + responseString);
if (responseString.equals("SUCCESS")) {
return true;
} else {
return false;
}
}
I hope this helps you. If you have any doubts, please email me at rames.p@gmail.com
Having the EditText boxes filled with the values, rotating the phone clears the data. this is just because the Activity is getting restarted on the configuration change. The orientation and hardware keyboard show/hide are the common reason which is a part of the configuration change. Due to this, the EditText and other Widgets in the Android Activity can get reset.
To avoid this, the following flag must be used in AndroidManifest.xml file.
android:configChanges="keyboard|keyboardHidden|orientation"
I hope this will help your code!..
As I promised here is the link which talks about how exactly the program has to be written to support both the versio of android os [1.6 and 2.0] while accessing its contacts.
http://www.higherpass.com/Android/Tutorials/Working-With-Android-Contacts/2/
The contact API is really complex to understand at first.
As per my experience, I am using the android 1.6 contact api to write the data in to the contact database. But, while reading the contact information, I am in need to use the Android 2.0 specific apis. Soon, I will post how to write a generic code to access the contact data in both the Android 2.0 and above the devices along with the Android 1.6 devices.