Monday, July 6, 2015

Mix-Panel Integration in android .


Step 1 - Add Google Play Services to your project.
Google play services are required to build the Mixpanel lib.
Step 2 - Download the latest Mixpanel library release
To use the Mixpanel library inside of Eclipse, download the latest library source from Github and extract it. ( )
Step 3 - Import the Mixpanel library into your project's workspace:
Step 4 - Associate the library as a dependency of your project:
(Google play services && Mixpanel library ) Google play services are dependency to Mixpanel.
Step 6 - Add permissions to your AndroidManifest.xml:
<!--This permission is required to allow the application to send events and properties to Mixpanel.-->
  <uses-permission android:name="android.permission.INTERNET" />
<!--  This permission is optional but  recommended so we can be smart about when to send data. -->
<uses-permission  android:name="android.permission.ACCESS_NETWORK_STATE" />

<!--  This permission is optional but recommended so events will contain information about
 bluetooth state -->
<uses-permission  android:name="android.permission.BLUETOOTH" />

Error : That is Facing at time of integration ;
1. Problem   :  import; (unable to resolve package name.)
          Solution  :  find Library in android_sdk\extras\android\support\annotations

At this point, you're ready to use the Mixpanel library inside Eclipse!

Getting Your Token  :
Go to website :
Create Project:
inside your project : user Profile : get your token : "1ef7e30d2a58d27f4b90c42e31d6d7ad"

Thursday, August 14, 2014

java tricks

1. Run java program without a class.

public enum AAA {


    public static void main(final String[] args) {

But an Enum is a class: it just a trick.

2. all about bits in java :- detail explanation

3.How to create java executable file in java ,means jar file .as my experience I never created jar file using cmd I always preferred eclipse to creating jar file .

Tuesday, August 12, 2014

complete jquary examples

1. complete drag and drop example in jquery .
download from the link below :

2. Draw on canvas complete example in javascript drawing start from where you left the mouse in last.
download from the link below :

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  ( ) .

                        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);
                                                                                                           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
                                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)
                                                                // k1 String to store ip as 192.168.1.
                                                                k1 = str1.substring(0, str1.lastIndexOf(".") + 1);
                                                                //if your system does not connected to any network local system loop back ip
                                                                // Refresh method to check Reachable ip address
                                                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);
                                                                                                try {
                                                                                                catch (InterruptedException e)


Wednesday, July 30, 2014

Threading concept

The basic of Thread
A thread is a part of a process. A thread lives within a process. No process, no thread. To understand better, we cannot keep our brain outside for sometime and place it back; it is because brain is a part of human body. Similarly, a thread cannot be there without a process. Infact, a process is divided into a number of threads.
 "A thread is a single sequential flow of control within a process". It is something confusing. A thread comprises of a block statements. These statements are executed one-by-one sequentially. Every thread maintains its own execution context within a process context area. We can say, a thread is a sub process. For execution, one thread does not depend on other; every thread is independent of other. This tutorial gives you how to divide a process into a number of threads or to say, how to create threads, how to assign different tasks, priorities and synchronization.

Lightweight process and Heavyweight process

If the execution shifts between the threads of the same process, it is known as lightweight process. If the execution shifts between the threads of different processes, it is known as heavyweight process.

Advantages of Multithreading

Microprocessor idle time is reduced and consequently output is obtained faster. When a program is divided into number of threads, each comprising a few statements, the code becomes simplerreadability increasesdebugging and maintenance becomes easier. Generally, user's input is very slow in GUI environment. This late user's response is best utilized by other threads (reduces overall execution time).
Applications of Multithreading/Multiprocessing

  1. Playing media player while doing some activity on the system like typing a document.
  2. Transferring data to the printer while typing some file.
  3. Downloading some files like images while browsing is going on (downloading images is very slow).
  4. Running animation while system is busy on some other work.
  5. Honoring requests from multiple clients by an application/web server.
  6. Threads are useful in handling events generated by components like mouse etc. A thread is capable to produce a frame with images.

Java API support for Threads
Multithreading is one of the built-in and important feature of Java language. Java's built-in classes, useful to develop a multithreaded program, are hereunder and all are from java.lang package.

Common Exceptions in Threads
The following are common exceptions that come in thread programming. All are from java.lang package.
  1. InterruptedException : It is thrown when the waiting or sleeping state is disrupted by another thread.
  2. IllegalStateException : It is thrown when a thread is tried to start that is already started.

Types of thread:
In java thread is of 2 types
1.     system defined thread
2.     user defined thread


These threads are known as daemon thread which are managed by JVM or Java Runtime system.These are predefined system level codes developed by sun microsystem .

Types of daemon thread:

garbage collector






These threads are guided by predefined threads. The thread class provides a predefined method through which the user defined threads are converted to daemon thread.
This method is final void setdaemon(boolean b);

States of thread

1.     New state :
 After the creations of Thread instance the thread is in this state but before the start() method invocation. At this point, the thread is considered not alive.
2.     Runnable (Ready-to-run) state :
 A thread start its life from Runnable state. A thread first enters runnable state after the invoking of start() method but a thread can return to this state after either running, waiting, sleeping or coming back from blocked state also. On this state a thread is waiting for a turn on the processor.
3.     Running state  A thread is in running state that means the thread is currently executing. There are several ways to enter in Runnable state but there is only one way to enter in Running state: the scheduler select a thread from runnable pool.
4.     Dead state  A thread can be considered dead when its run() method completes. If any thread comes on this state that means it cannot ever run again.
5.     Blocked - A thread can enter in this state because of waiting the resources that are hold by another thread.

Introduction to Threads in java

Introduction to Threads

sMultithreading refers to two or more tasks executing concurrently within a single program. A thread is an independent path of execution within a program. Many threads can run concurrently within a program. Every thread in Java is created and controlled by the java.lang.Thread class. A Java program can have many threads, and these threads can run concurrently, either asynchronously or synchronously.

Comparative to other languages, multithreading is very easy and simple in Java. The built-in support for threads is simple and straight so that any programmer can do with multithreading operations without confusion and special attention. Multithreading uses very effectively the microprocessor time by reducing its idle time. When the processor's idle time is reduced, the output of the programs comes earlier.

Concept to understand :-

Multitasking, Multiprocessing and Multithreading
A program under execution is called a process. : "performing multiple tasks at the same time is called multitasking ". This is very wrong and is the result of misunderstanding the concept.

Every computer person knows well that microprocessor can execute only one instruction (task) at a time. That is, the earlier definition is going wrong somewhere else. This is the point of confusion about multithreading for everyone.
When a process is being executed, there may be an interruption, sometimes, for execution; for example, a keyboard input (scanf) may not be fed immediately. When not fed, the execution is halted (observe, the cursor will be blinking even for the whole day when the input is not given).
 Now the processor is free and idle. We can ask the microprocessor to do another process meantime. The processor obliges (as underlying OS supports multitasking). Now, two programs are under execution – the first one half the way completed and kept apart and the other being executed. When the second task (process) is over, if the input is ready, the control will be shifted to the first process and now the first process is executed completely. The result is output of both the programs is obtained earlier. All this is transparent (not known) to the user as context switching occurs at very fast speed.

1.   Multitasking
"Shifting the microprocessor to execute another process when the first process is stopped its execution, is known as multitasking". Shifting between the processes is known as context switching. Do not shift unnecessarily when the first program is going smooth with its execution as context switching takes more time and performance looses. Shift only when a running process is stopped for some reason.
2.     Multiprocessing
Putting multiple processors (say two) and feeding multiple processes simultaneously is known as multiprocessing and is a very rare phenomenon as multiple processors on desktop PCs is uncommon (only super computers have).
3.   Multithreading
Multithreading is the Java's style of achieving multitasking. A single Java program can be divided into a number of threads and executed simultaneously while shifting between the threads when one stops its execution. The current tutorial discusses how to divide a Java program into multiple threads and how to execute them.
Simultaneously, concurrently, parallel

"At the same time" is a confusing idiom. Many processes may exist whose execution is stopped in the middle for some reason. Remember, only one can be active at any time. Which ever process is ready is called and executed. "Many" must be interpreted this way. It looks all at a time as context switching happens very fast (like cinema where a number of frames of images are run is such a speed, our eye cannot catch).

Another term to understand :

Preemptive multitasking and Time-sharing

1.     Preemptive multitasking
At a given time, a number of processes may be getting executed on the CPU. CPU allocates a certain period of time, known as time-slice, for each process to execute. Each process is guaranteed of a time-slice. In preemptive multitasking ,

2.   Time-sharing
one process empties (forcibly evacuating) the other process for the time-slice period and thus every process definitely gets the CPU time. Thus, CPU time is shared by all the processes and is known as time sharing. Time sharing is a CPU architecture where CPU distributes its time equally to all the processes waiting for execution.

Preemptive and Cooperative Multitasking

In multitasking two types of algorithms exists
– preemptive multitasking and cooperative multitasking.

Each process is allotted a certain period of time known as time slice. With time slices, the waiting processes get evenly all the CPU time and one process cannot hold the CPU time as long it wants.
one process can hold the microprocessor time as long as it would like. But the CPU is empowered to remove the process if the process does not utilize the time after holding it. Preemptive multitasking is supported by OS/2, UNIX, Windows NT etc. Cooperative multitasking is supported by Windows 3.1, UNIX, Windows NT etc.

When an immediate action or attention is required, like keyboard input or a button click, preemptive is preferred. The disadvantage of cooperative multitasking is, if designed poorly, it may hang the system.

Preemptive Scheduling and Non-preemptive Scheduling
For forcing the thread to vacate the microprocessor, two properties can be considered – priority and waiting time.

 In preemptive scheduling, a thread with more priority vacates the executing thread of low priority. That is, low-priority thread yields to the high-priority thread.
In non-preemptive scheduling, waiting time is considered and not priority. That is, the high-priority thread cannot relinquish a low-priority thread having more waiting time.

Monday, July 28, 2014

Getting start with  Android

Step 1:
The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android. If you're a new Android developer, we recommend you download the ADT .
With a single download, the Eclipse ADT bundle includes everything you need to begin developing apps:
·       Eclipse + ADT plugin
·       Android SDK Tools
·       Android Platform-tools
·       A version of the Android platform
·       A version of the Android system image for the emulator
Step 2:

Create a Project with Eclipse :
Set following field -:
Application Name :
Project Name :
Package Name:
Leave other field as it is or you can change according to your requirement ,leave the default selections and click Next.
Step 3:
The next screen can help you create a launcher icon for your app.
Step 4:
Now you can select an activity template from which to begin building your app.
For this project, select BlankActivity and click Next.
Leave all the details for the activity in their default state and click Finish.
Now you create “hello world ” project.