How can I send result data from Broadcast Receiver to Activity

You can call the receiver from your activity. If you don’t want to add the logic of the receiver in you activity you can use an abstract receiver. You abstract receiver: public abstract class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //Add you receiver logic here … … onNewPosition(); } … Read more

jquery autocomplete with json response

$(“#users-allowed”).autocomplete(“/people/following.json”, { width: 320, dataType: ‘json’, highlight: false, scroll: true, scrollHeight: 300, parse: function(data) { var array = new Array(); for(var i=0;i<data.items.length;i++) { array[array.length] = { data: data.items[i], value: data.items[i], result: data.items[i].username }; } return array; }, formatItem: function(row) { var name=””; if (row.first_name && row.last_name) name=”(“+row.first_name+’, ‘+row.last_name+’)’; else if (row.first_name) name=”(“+row.first_name+’)’; else if (row.last_name) … Read more

How can I output data before I end the response?

There actually is a way that you can do this without setting Content-Type: text/plain and still use text/html as the Content-Type, but you need to tell the browser to expect chunks of data. This can be done easily like this: var http = require(‘http’); http.createServer(function(request, response) { response.setHeader(‘Connection’, ‘Transfer-Encoding’); response.setHeader(‘Content-Type’, ‘text/html; charset=utf-8’); response.setHeader(‘Transfer-Encoding’, ‘chunked’); response.write(‘hello’); … Read more

What is the difference between response.sendRedirect() and request.getRequestDispatcher().forward(request,response) [duplicate]

To simply explain the difference, response.sendRedirect(“login.jsp”); doesn’t prepend the contextpath (refers to the application/module in which the servlet is bundled) but, whereas request.getRequestDispathcer(“login.jsp”).forward(request, response); will prepend the contextpath of the respective application Furthermore, Redirect request is used to redirect to resources to different servers or domains. This transfer of control task is delegated to the … Read more

What are Content-Language and Accept-Language?

Content-Language, an entity header, is used to describe the language(s) intended for the audience, so that it allows a user to differentiate according to the users’ own preferred language. Entity headers are used in both, HTTP requests and responses.1 Accept-Language, a request HTTP header, advertises which languages the client is able to understand, and which … Read more

No response from MediaWiki API using jQuery

You need to trigger JSONP behavior with $.getJSON() by adding &callback=? on the querystring, like this: $.getJSON(“http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=”+title+”&format=json&callback=?”, function(data) { doSomethingWith(data); }); You can test it here. Without using JSONP you’re hitting the same-origin policy which is blocking the XmlHttpRequest from getting any data back.

Create HTTP post request and receive response using C# console application

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net; using System.IO; namespace WebserverInteractionClassLibrary { public class RequestManager { public string LastResponse { protected set; get; } CookieContainer cookies = new CookieContainer(); internal string GetCookieValue(Uri SiteUri,string name) { Cookie cookie = cookies.GetCookies(SiteUri)[name]; return (cookie == null) ? null : cookie.Value; } public string GetResponseContent(HttpWebResponse response) … Read more

C# Asp.net write file to client

You could use the Response.ContentType like this Response.ContentType = “text/plain”; Response.OutputStream.Write(buffer, 0, buffer.Length); Response.AddHeader(“Content-Disposition”, “attachment;filename=yourfile.txt”); This of course works if you want to write a text file. In case you want to write a .doc for example you change the ContentType to “application/msword” etc…