I am novice to android, I am facing coding problem. I have used the code from novice' tutorials. I am using eclipse 3.3 and Android 0.9 beta SDK and Jdk 1.6.
I m getting error in this code ....please can anyone help me?
Using java Syntax Highlighting
- package c.d;
- import java.io.ByteArrayInputStream;
- import java.io.UnsupportedEncodingException;
- import java.net.URLEncoder;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.Map;
- import org.apache.http.util.ByteArrayBuffer;
- import android.app.Activity;
- import android.app.NotificationManager;
- import android.net.http.EventHandler;
- import android.net.http.Headers;
- import android.net.http.RequestQueue;
- import android.net.http.SslCertificate;
- import android.net.http.SslError;
- import android.os.Bundle;
- import android.util.Log;
- public class acaa extends Activity {
- private final String DEBUG_TAG = "httpPostExample";
- String tag = "PRATIK";
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- String POSTText = null;
- android.net.http.RequestQueue rQueue = new RequestQueue(this);
- try {
- POSTText = "mydata="
- + URLEncoder.encode("Pratik", "UTF-8");
- } catch (UnsupportedEncodingException e) {
- return;
- }
- byte[] POSTBytes = POSTText.getBytes();
- ByteArrayInputStream baos = new ByteArrayInputStream(POSTBytes);
- Map<String, String> headers = new HashMap<String, String>();
- headers.put("Content-Type", "application/x-www-form-urlencoded");
- MyEventHandler myEvH = new MyEventHandler(this);
- rQueue.queueRequest("http://192.168.5.231:8084/Picasa/Index.jsp",
- "POST", headers, myEvH, baos, POSTBytes.length, false);
- rQueue.waitUntilComplete();
- Log.i(tag, "End");
- }
- private class MyEventHandler implements EventHandler {
- private static final int RANDOM_ID = 0x1337;
- ByteArrayBuffer baf = new ByteArrayBuffer(20);
- private Activity myActivity;
- MyEventHandler(Activity activity) {
- this.myActivity = activity; }
- public void data(byte[] bytes, int len) {
- baf.append(bytes, 0, len); }
- public void endData() {
- String text = new String(baf.toByteArray());
- myShowNotificationAndLog("Data loaded: \n" + text); }
- public void status(int arg0, int arg1, int arg2, String s) {
- myShowNotificationAndLog("status [" + s + "]"); }
- public void error(int i, String s) {
- this.myShowNotificationAndLog("error [" + s + "]"); }
- public void handleSslErrorRequest(int arg0, String arg1, SslCertificate arg2) { }
- public void headers(Iterator arg0) { }
- public void headers(Headers arg0) { }
- private void myShowNotificationAndLog(String msg) {
- /* Print msg to LogCat and show Notification. */
- Log.d(DEBUG_TAG, msg);
- nm.notifyWithText(RANDOM_ID, msg, NotificationManager.LENGTH_LONG, null);
- Log.i(tag, ""+msg);
- }
- public void certificate(SslCertificate arg0) {
- // TODO Auto-generated method stub
- }
- public void handleSslErrorRequest(SslError arg0) {
- // TODO Auto-generated method stub
- }
- }
- }
Parsed in 0.060 seconds, using GeSHi 1.0.8.4
I m getting errors at two places
1) rQueue.waitUntilComplete()
The method waitUntilComplete() is undefined for the type RequestQueue
2)nm.notifyWithText(RANDOM_ID, msg, NotificationManager.LENGTH_LONG, null);
NotificationManager.LENGTH_LONG cannot be resolved


