Small pieces of code that can be copy/paste-ed on your project

Android HttpResponse content(body) to String

Snippets, Solutions
Usually I use the following code to convert a Http response content to String:   BufferedReader in = new BufferedReader(new InputStreamReader(response.getEntity().getContent())); StringBuilder responseBuilder = new StringBuilder(); String line = ""; while…

Android – Load a String into WebView

Snippets, Solutions
To load html data from a String into a WebView, you can use the following method: yourWebView.loadDataWithBaseURL("x-data://base", stringToLoadInWebView, "text/html", "UTF-8", null); Note that the UTF-8 charset might be different for…

Set the application icon

To set the application icon in Android you have to open the project’s Manifest.xml file and add the following attribute to the application tag: <application android:icon="drawable resource"> Before you do that…

Add image to email intent in Android

Snippets, Solutions
How to add image to an email intent in Android: // build a email sending intent Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("image/png"); // set the email subject emailIntent.putExtra(Intent.EXTRA_SUBJECT, "email subject");…
Exit mobile version