Android EntityTemplate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android EntityTemplate class.

This code example shows how to use the following methods: setContentType
                statusCode == HttpStatus.SC_NOT_MODIFIED) {
            return; 
        } 
 
        EntityTemplate body = createEntity();
        body.setContentType(contentType);
        response.setEntity(body);
    } 
 
    private EntityTemplate createEntity() {
        return new EntityTemplate(new ContentProducer() {
            public void writeTo(OutputStream outputStream) throws IOException {
                OutputStreamWriter writer = new OutputStreamWriter(outputStream, "UTF-8");
                writer.write(payload);
                writer.flush();
            } 
        }); 
    } 
 
    public void setStatusCode(int statusCode) {
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setContentType
                    System.out.println("File " + file.getPath() + " not found"); 
 
                } else if (!file.canRead() || file.isDirectory()) { 
 
                    response.setStatusCode(HttpStatus.SC_FORBIDDEN); 
                    EntityTemplate body = new EntityTemplate(new ContentProducer() {
 
                        public void writeTo(final OutputStream outstream) throws IOException { 
                            OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8"); 
                            writer.write("<html><body><h1>"); 
                            writer.write("Access denied"); 
                            writer.write("</h1></body></html>"); 
                            writer.flush(); 
                        } 
 
                    }); 
                    body.setContentType("text/html; charset=UTF-8"); 
                    response.setEntity(body); 
                    System.out.println("Cannot read file " + file.getPath()); 
 

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setContentType
                System.out.println("File " + file.getPath() + " not found"); 
                 
            } else if (!file.canRead() || file.isDirectory()) { 
                 
                response.setStatusCode(HttpStatus.SC_FORBIDDEN); 
                EntityTemplate body = new EntityTemplate(new ContentProducer() { 
                     
                    public void writeTo(final OutputStream outstream) throws IOException {
                        OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8"); 
                        writer.write("<html><body><h1>");
                        writer.write("Access denied");
                        writer.write("</h1></body></html>");
                        writer.flush();
                    } 
                     
                }); 
                body.setContentType("text/html; charset=UTF-8"); 
                response.setEntity(body); 
                System.out.println("Cannot read file " + file.getPath()); 
                 

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setContentType
				HttpContext httpContext) throws HttpException, IOException {
			 
			final String uri = URLDecoder.decode(request.getRequestLine().getUri());
			final List<NameValuePair> params = URLEncodedUtils.parse(URI.create(uri),"UTF-8");
			 
			EntityTemplate body = new EntityTemplate(new ContentProducer() {
				public void writeTo(final OutputStream outstream) throws IOException {
					OutputStreamWriter writer = new OutputStreamWriter(outstream, "UTF-8");
					writer.write("{");
					if (SpydroidActivity.lastCaughtException!=null) { 
						String lastError = SpydroidActivity.lastCaughtException.getMessage();
						writer.write("\"lastError\":\""+(lastError!=null?lastError:"unknown error")+"\",");
						writer.write("\"lastStackTrace\":\""+SpydroidActivity.lastCaughtException.getStackTrace().toString()+"\",");
					} 
					writer.write("\"cameraInUse\":\""+Session.isCameraInUse()+"\",");
					writer.write("\"microphoneInUse\":\""+Session.isMicrophoneInUse()+"\",");
					writer.write("\"activityPaused\":\""+(SpydroidActivity.activityPaused?"1":"0")+"\"");
					writer.write("}");
					writer.flush();
					 

5
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android EntityTemplate Questions & Answers:

See Code Examples for Android EntityTemplate Methods: