Sponsored Links
Hi all, I'm currently trying to get an Android application to connect and send a protocol buffer to a servlet on App Engine. However, when I get to the line "OutputStream out = urlc.getOutputStream()" I get the exception that it "does not support output." I've not found many people with this issue, and no posted fixes apart from using newer SDKs. However, this is for a university project and I'm sticking to 1.5, so any help would be appreciated. The only other relevant information I can think of is I have added the uses internet permission, again I'm on SDK1.5 and I'm running in Eclipse. The code is as follows: package my.transferclient; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.URL; import java.net.URLConnection; import my.tft.protos.RandomMessageProtos.Note; import my.tft.protos.RandomMessageProtos.RandomMessage; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class TransferClient extends Activity { private final static String TAG = "TransferClient"; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { URL url = new URL(" http://10.0.2.2 :8080/testfileupload"); URLConnection urlc = url.openConnection(); OutputStream out = urlc.getOutputStream(); RandomMessage.Builder rm = RandomMessage.newBuilder(); Note.Builder note = Note.newBuilder(); note.setName("Blargy McBlarg"); note.setMessage("This is a random message"); rm.addNote(note); rm.build().writeTo(out); out.close(); BufferedReader rd = new BufferedReader(new InputStreamReader (urlc .getInputStream())); String line; System.out.println("Respose is:"); while ((line = rd.readLine()) != null) { System.out.println(line); } rd.close(); } catch (Exception e) { Log.v(TAG, e.getMessage()); } // catch } } --