Skip to content

Instantly share code, notes, and snippets.

View msomu's full-sized avatar

Somasundaram M msomu

View GitHub Profile
@msomu
msomu / MyActivity.java
Created November 1, 2014 04:58
Button click on Android method 1
public void doSomething(View v){
if(v.getId()==R.id.button1){
Log.d("SOMU","Button was clicked");
}
}
@msomu
msomu / AndroidManifest.xml
Created November 1, 2014 04:33
Know when the users change their phone orientation to Landscape or Potrait
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize">
@msomu
msomu / AndroidMainfest.xml
Created November 1, 2014 04:14
To make an Activity just Landscape.
<activity
android:name=".MyActivity"
android:label="@string/app_name"
android:screenOrientation="landscape">
@msomu
msomu / IncrementOperator.java
Created October 31, 2014 14:21
Inc dec operators
import java.util.Scanner;
public class IncrementOperator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int pen = 5;
int pencil = 1;
//Post increment
@msomu
msomu / MathOperators.java
Created October 31, 2014 13:50
Som basic maths operations on Java
import java.util.Scanner;
public class MathOperators {
public static void main(String []args){
Scanner sc = new Scanner(System.in);
int girls,boys,people;
girls = sc.nextInt();
boys= sc.nextInt();
@msomu
msomu / BasicCalc.java
Created October 31, 2014 12:58
This is a basic add from user
import java.util.Scanner;
public class BacisCalc {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double fnum,snum,answer;
System.out.println("Enter the First number: ");
fnum = sc.nextDouble();
@msomu
msomu / ReadInput.java
Created October 31, 2014 12:05
This code helps you to read a line from the user
import java.util.Scanner;
public class ReadInput {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(sc.nextLine());
}
}
@msomu
msomu / Variables.java
Last active August 29, 2015 14:08
Variable in Java
public class Variables {
public static void main(String[] args) {
int i=5;
System.out.print("The number is ");
System.out.print(i);
System.out.println(".");
System.out.print("It can also be written as this "+i);
}
@msomu
msomu / HelloWorld.java
Created October 31, 2014 10:50
This was my first Java Code
public class HelloWorld {
public static void main(String[] args) {
System.out.print("Hello World");
}
}
@msomu
msomu / jsonArrayParse.java
Last active August 29, 2015 14:07
JSON Array Parsing in android
try {
JSONArray flimsJSON = new JSONArray(s);
int numVideos = flimsJSON.length();
for(int i =0; i<numVideos;i++){
JSONObject titleJSON = (JSONObject) flimsJSON.get(i);
String titleString = titleJSON.getString("title");
Log.d("TITLE:",titleString);
}
Log.d("Number of MOVIES FETCHED","is"+numVideos);
} catch (JSONException e) {