Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.Random;
import android.graphics.Color;

public class Main {
    /**
     * get random color rgb value
     * @return rgb color int
     */
    public static int getRandomColor() {
        Random random = new Random();
        /*
         * Better limiting value.
         * if value is too small, it will appear lighter
         * if value is too large, it will appear darker
         */
        //limit within 50-199
        int red = random.nextInt(150) + 50;
        int green = random.nextInt(150) + 50;
        int blue = random.nextInt(150) + 50;
        //create a color int as per rgb and return
        return Color.rgb(red, green, blue);
    }
}