Skip to main content



There is a new version of the app. Click on the picture below:

Depending on whether or not the device is connected to the internet, Random generates Pseudo random and Real Random (using numbers. Users can simulate a die roll, a coin flip or use A DIY random number generator. A string randomiser option, which randomises string input, is also available.

Checking whether the device is connected to the internet:

private boolean haveNetworkConnection() {
 ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
 NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
 return activeNetworkInfo != null && activeNetworkInfo.isConnectedOrConnecting();

It is also necessary to check if the device can actually connect to This is to take into consideration of the case where servers might be down occasionally, or, the device is connecting to a router with no DNS and/or IP set up.

 result = Integer.parseInt(readRandom());
 text.setText("Real Random");
catch (UnknownHostException e)
 result = pseudoRandom();
 text.setText("Pseudo Random");
 Toast.makeText(getApplicationContext(), "HTTP Time-Out\nCheck connection", Toast.LENGTH_LONG).show();

Getting Real random from 

The following lines of code is for the DIY option. Everything else uses a simple modification. For example, the min and max for the Roll a Die option would be 1 and 6 respectively.

public String realRandom(String min, String max) throws Exception {
 String sendto = "" + min + "&max=" + max + "&col=1&base=10&format=plain&rnd=new";
 URL url = new URL(sendto);
 BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
 return (in.readLine());

Popular posts from this blog



The Zorganian Republic has some very strange customs. Couples only wish to have female children as only females can inherit the family's wealth, so if they have a male child they keep having more children until they have a girl. If they have a girl, they stop having children. What is the ratio of girls to boys in Zorgania?
The ratio of girls to boys in Zorgania is 1:1. This might be a little counter-intuitive at first. Here are some ways of tackling this problem. 1. Monte Carlo Simulation: Although, Monte Carlo simulation does not necessarily show why the result is 1:1, it is appropriate because of the very counter-intuitive nature of the problem. At the very least, it helps us see that the result is indeed 1:1. Therefore, this is a good start.
The following R code estimates the probability of a child being a boy in Zorgania. 
couples <-100000 boycount <-0for (i in1:couples){ # 0: boywhile (sample(c(0,1),1) ==0) { boycount=boycount+1 } } probability <- boycount/(co…

Simple Launcher

A simple minimal launcher application for Android devices that shows battery percentage using lzyzsd's CirclProgress library (ArchProgress used in this case) and BroadcastReciever for battery state, Android's clock widgets, a built-in flash light switch and an app list view that can be toggled. Currently, the toggle simply filters all the app that I am working on at present. Future implementation can allow users to select their favorite apps or populate second toggle based on the most used applications.