Download Stuff From Reddit Using Java

Previously I’ve looked at how to download stuff from Reddit. So I thought I’ll re-apply the same code, but using Java. Here is the same code to do just that. import java.io.*; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.charset.Charset; import java.nio.file.*; import java.util.Arrays; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class getWallpaper { private static final String OPEN_SUBREDDIT = "http://www.reddit.com/r/%s/.json"; public static String readAll(Reader rd) throws IOException { StringBuilder sb = new StringBuilder(); int cp; while ((cp = rd. [Read More]

Developing On Android Adding Dialogs And Wrapping Up

This is a series of post as I will hopefully build a simple wallpaper app. In this post, we will build a simple “guess the number game”. There will be a input area, which you enter you guess, and simple prompt to tell you whether your guess was too high or too low. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".LowerHigher"> <TextView android:text="Enter a Guess. The random number will be between 1-10 inclusive. [Read More]

Developing On Android Using Buttons

This is a series of post as I will hopefully build a simple wallpaper app. In this app, we will build a simple counter which counts the number of times a button in the app was pressed. Firstly we should design layout of the app. It should have text which is the counter and a button. Be give the button and the counter id’s so that it can be referenced in our code. [Read More]

Develping On Android Hello World

This is a series of post as I will hopefully build a simple wallpaper app. When creating a new application using Android Studio, you will immediately be given a “Hello World!” boilerplate. But how can you extend it? But firstly, let’s have a quick look at the different files which build up an Android app. res/layouts I like to think of layouts as your HTML code. It tells you where everything sits. [Read More]