Sunday, August 10, 2014

Creating android /java project

Creating android /java project with me based on socket programming. UDP/TCP in java. Using multithreading concept .

Concept :  transfer desktop/laptop screen to you android phone .
Requirement :
              Basic knowledge of java android programming .
Interface for application:
 We are creating  two applications. One for desktop/laptop and one for android. To communicate we use UDP/TCP socket.
Important thing about the project :
                It works for local network ,local wifi, hotspot etc. so let’s start working on it. Regarding any issue or for any further information contact me at  ( joshitechnology@gmail.com ) .


                        Project name: Projector application

                         6th month training project for cse/IT student. 



Android application interface looks as :


desktop application looks as



this application search for local available node in network by creating 255 threads. One important thing java JVM can create 20000 thread at a time .

Creating 255 threads in java

class MyThread1 extends Thread
   {
                   int k;
                                public MyThread1(int i)
                                                {
                                                                k = i;
                                                }
                                public void run()
                                                {
                                                try {
                                                InetAddress inet2 = InetAddress.getByName(InterFace.k1 + k);
                                                                                if (inet2.isReachable(1500))
                                                                                            {
                                                                                                       System.out.printf("Reachable ip  to your system : "+inet2);
                                                                                                }
                                                                                 else
                                                                                                  {
                                                                                                           System.out.printf("Not Reachable ip  : "+inet2);
                                                                                            }                                                             
                                                                                }
                                                                catch (Exception e)
                                                                                {
                                                                                                System.out.println("wht is this " + e.getMessage());
                                                                                }
                                                }
                }
class InterFace
                {
                                public static String k1 = null;
                                public static void main(String arg[]) throws UnknownHostException
                                                {
                                                                Check_ip();
                                                }
                                public static void Check_ip()
                                                {
                                                                //main method  getting ip address of local system in wifi
                                                                String str1=null;
                                                                try {
                                                                                                str1 = new String(Inet4Address.getLocalHost().getHostAddress());
                                                                                }
                                                                catch (UnknownHostException e)
                                                                                {
                                                                                                e.printStackTrace();
                                                                                }
                                                                // k1 String to store ip as 192.168.1.
                                                                k1 = str1.substring(0, str1.lastIndexOf(".") + 1);
                                                                System.out.println(k1);
                                                               
                                                                //if your system does not connected to any network local system loop back ip
                                                                if(k1.equals("127.0.0."))
                                                                str1=null;
                               
                                                                // Refresh method to check Reachable ip address
                                                                Refresh();
                                                }
 
                                                public static void Refresh()
                                                {
                                               
                                                                //create 255 Thread using for loop
                                                                for (int x = 0; x < 256; x++)
                                                                                {
                                                                                                // Create Thread class
                                                                                                MyThread1 temp = new MyThread1(x);
                                                                                                temp.start();
                                                                                                try {
                                                                                                                                temp.join(10);
                                                                                                                }
                                                                                                catch (InterruptedException e)
                                                                                                {
                                                                                                                                e.printStackTrace();
                                                                                                }
                                                                                }
 
                                                }

                }

No comments:

Post a Comment