Sunday, August 24, 2014

Android Eclipse tips: switch between Automatic and manual target modes

In Eclipse and ADT, you can select launching your app automatically select suitable AVD/device, or manually select.

By default, a run configuration uses the automatic target mode in order to select an AVD/device. If your run configuration uses manual mode, then the "device chooser" is presented every time that your application is run, so that you can select which AVD/device to use.
http://developer.android.com/tools/building/building-eclipse.html#RunConfig

To set Run Configuration:
  • Right click your project -> Run As -> Run Configurations...
  • or, Click the arrow (downward) beside the Play button (green arrow) on the top menu -> Run Configurations...
In Run Configuration Dialog, select your project under Android Application on the left, select Target, then select your expect Deployment Target Selection Mode.



Migrating to Android for iOS Developers

Migrating to Android for iOS Developers gives you—as an experienced native iOS app developer—the skills to learn native Android apps development from scratch. Starting with preparing your Android integrated development environment and introducing just enough Android application framework fundamentals, you’ll understand how to create a simple but meaningful HelloAndroid project immediately.

Migrating to Android for iOS Developers

This book provides the guidelines and tutorial projects to show you how to translate your existing iOS app to the Android platform. You’ll use your mobile app knowledge to structure your Android apps in a similar way to how you would structure your iOS apps. To implement use cases with detailed screens, the most common mobile topics are discussed, including user interfaces, managing data, and networking with remote services. As you move through the book, you’ll create Android apps with rich UI components to handle common CRUD operations locally and remotely.

There are many Android goodies described in the book. Instead of relying on routine text descriptions, you’ll discover the uniqueness of Android and appreciate the many features that are unique to the platform. This book also explores more powerful mobile UX patterns that are commonly used on the iOS and Android platforms.

When you finish reading Migrating to Android for iOS Developers, you’ll be an Android developer as well as an iOS developer. And, you will be fully convinced you can do everything in Android that you can do in iOS.
What you’ll learn
• How to maximize your existing iOS mobile knowledge to learn Android programming skills
• How to use the Android integrated development environment with the Eclipse ADT plugin
• How to translate your existing iOS code to Android with the following common mobile topics:
° Common mobile screen navigation patterns
° User interface components and UI animations
° Storing data
° Networking and using remote services
° Using system apps
° Maps and location awareness
° Mobile search frameworks
° Mobile analytics

Who this book is for
This book is for iOS app developers—like you—who want to port their native iOS app to become an Android app. Also, if you are not an iOS developer, but already familiar with mobile apps, then this book can also help you understand Android development with step-by-step instructions and tutorial projects.

Table of Contents
1. Setup Development Environment
2. Android Programming BasicsChapter
3. Structure your App and Break it into Components
4. Implement Piece by Piece
5. More About Android Application Components
6. Android Application Resources
7. Common Mobile Use Cases
8. Pulling it all together - Recap with a Case Study
9. Appendix

Beginning Google Glass Development

Beginning Google Glass Development is your number one resource for learning how to develop for Google Glass--the paradigm-shifting mobile computing platform taking the world by storm now and for years to come. Mobile developers have always had to think for the future, and right now that means getting started with Google Glass.

Beginning Google Glass Development

This book is incredibly hands-on with many exciting projects. You will learn the basics of Glass and how to set up your development environment, through to every Glass development topic using Glass Development Kit (GDK):
• Glass User Interface
• Camera and Image Processing
• Video: Basics and Applications
• Voice and Audio
• Network, Bluetooth, and Social
• Locations, Map, and Sensors
• Graphics, Animation, and Games

You will also learn how to develop enterprise and web-based Glass apps using the Mirror API. Each topic is full of examples that illustrate what Glass can truly do and help you quickly start developing your own apps.

Jeff Tang has successfully developed mobile, web, and enterprise apps on many platforms, and cares immensely about user experience. He brings his vast knowledge to this book through cool and practical examples, which will excite and tantalize your creativity.

This book is for any developer who is keen to start developing for Glass with GDK or the Mirror API. Whether you are an Android, iOS, web, or enterprise developer, you do not want to miss the chance that Glass becomes the next big thing. Get started with Beginning Google Glass Development and be inspired today.

What you’ll learn
• Glass User Interface
• Camera and Image Processing
• Video: Basics and Applications
• Voice and Audio
• Network, Bluetooth, and Social
• Locations, Map, and Sensors
• Graphics, Animation, and Games

Who this book is for
This book is for any developer who is keen to start developing for Glass. You may have worked with iOS apps, Android apps, or both – but you can start developing with Glass today using this book.

Table of Contents
01 - Getting Started
02 - Hello Glass! Your First GDK Glassware
03 - Glass User Interface
04 - Camera and Image Processing
05 - Video: Basics and Applications
06 - Voice and Audio
07 - Networking, Bluetooth, and Social
08 - Locations, Maps, and Sensors
09 - Graphics, Animations, and Games
10 - The Mirror API (The Mirror API and Enterprise Apps)

Thursday, August 21, 2014

PhoneGap 3.x Mobile Application Development Hotshot

Create useful and exciting real-world apps for iOS and Android devices with 12 fantastic projects with this book and ebook.

PhoneGap 3.x Mobile Application Development Hotshot

Overview
  • Use PhoneGap 3.x effectively to build real, functional mobile apps ranging from productivity apps to a simple arcade game
  • Explore often-used design patterns in apps designed for mobile devices
  • Fully practical, project-based approach to give you the confidence in developing your app independently
In Detail

PhoneGap allows you to use your existing knowledge of HTML, CSS, and JavaScript to create useful and exciting mobile applications.

This book will present you with 12 exciting projects that will introduce you to the dynamic world of app development in PhoneGap. Starting with their design and following through to their completion, you will develop real-world mobile applications. Each app uses a combination of core PhoneGap technologies, plugins, and various frameworks covering the necessary concepts you can use to create many more great apps for mobile devices.

What you will learn from this book
  • Explore localization and globalization
  • Create, save, and retrieve data using persistent device storage
  • Record audio using a microphone
  • Capture images and video using a camera
  • Share content to social media networks
  • Optimize your app for tablet-sized devices
  • Locate the user's device using geolocation
  • Interact with the accelerometer to create a fun arcade game
  • Use core and third-party plugins to extend PhoneGap
  • Look at mobile application design patterns
Approach

A practical guide written in a tutorial-style, this book walks you step-by-step through 12 individual projects to create real world apps. Each project moves through design and implementation of the app, and also provides suggestions to enhance it.

Who this book is written for

If you are a mobile developer who is familiar with Phonegap basics and wants to quickly create some cool mobile applications with Phonegap, this book is for you. You should have some experience working with JavaScript, HTML, CSS, and also be able to use your operating system's command-line interface. No experience with Java, C#, or Objective C is required.



Tuesday, August 19, 2014

Java Chat Server running on PC command line

The former post show how to "Implement simple Android Chat Application, server side" running on Android. Actually, it show info of IP/Port only, without any user interaction. This post is another command line version of the Chat Server in Java, it can run on PC's ommand Line. It can connected with "Simple Android Chat Application, client side".

The video show it was compiled with SDK 8, and run on command line, at PC running Ubuntu Linux.


JavaCmdChatServer.java
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

public class JavaCmdChatServer {

    static final int SocketServerPORT = 8080;

    String msgLog = "";

    List<ChatClient> userList;

    ServerSocket serverSocket;

    public static void main(String[] args) {
        JavaCmdChatServer ChatServer = new JavaCmdChatServer();

        while (true) {
        }
    }

    JavaCmdChatServer() {
        System.out.print(getIpAddress());
        userList = new ArrayList<>();
        ChatServerThread chatServerThread = new ChatServerThread();
        chatServerThread.start();

    }

    private class ChatServerThread extends Thread {

        @Override
        public void run() {
            Socket socket = null;

            try {
                serverSocket = new ServerSocket(SocketServerPORT);
                System.out.println("I'm waiting here: "
                    + serverSocket.getLocalPort());
                    System.out.println("CTRL + C to quit");

                while (true) {
                    socket = serverSocket.accept();
                    ChatClient client = new ChatClient();
                    userList.add(client);
                    ConnectThread connectThread = new ConnectThread(client, socket);
                    connectThread.start();
                }

            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (socket != null) {
                    try {
                        socket.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }

        }

    }

    private class ConnectThread extends Thread {

        Socket socket;
        ChatClient connectClient;
        String msgToSend = "";

        ConnectThread(ChatClient client, Socket socket) {
            connectClient = client;
            this.socket = socket;
            client.socket = socket;
            client.chatThread = this;
        }

        @Override
        public void run() {
            DataInputStream dataInputStream = null;
            DataOutputStream dataOutputStream = null;

            try {
                dataInputStream = new DataInputStream(socket.getInputStream());
                dataOutputStream = new DataOutputStream(socket.getOutputStream());

                String n = dataInputStream.readUTF();

                connectClient.name = n;

                msgLog = connectClient.name + " connected@"
                    + connectClient.socket.getInetAddress()
                    + ":" + connectClient.socket.getPort() + "\n";

                System.out.println(msgLog);

                dataOutputStream.writeUTF("Welcome " + n + "\n");
                dataOutputStream.flush();

                broadcastMsg(n + " join our chat.\n");

                while (true) {
                    if (dataInputStream.available() > 0) {
                        String newMsg = dataInputStream.readUTF();

                        msgLog = n + ": " + newMsg;
                        System.out.print(msgLog);
                        broadcastMsg(n + ": " + newMsg);
                    }

                    if (!msgToSend.equals("")) {
                        dataOutputStream.writeUTF(msgToSend);
                        dataOutputStream.flush();
                        msgToSend = "";
                    }

                }

            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                if (dataInputStream != null) {
                    try {
                        dataInputStream.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                if (dataOutputStream != null) {
                    try {
                        dataOutputStream.close();
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                userList.remove(connectClient);

                System.out.println(connectClient.name + " removed.");

                msgLog = "-- " + connectClient.name + " leaved\n";
                System.out.println(msgLog);

                broadcastMsg("-- " + connectClient.name + " leaved\n");

            }

        }

        private void sendMsg(String msg) {
            msgToSend = msg;
        }

    }

    private void broadcastMsg(String msg) {
        for (int i = 0; i < userList.size(); i++) {
            userList.get(i).chatThread.sendMsg(msg);
            msgLog = "- send to " + userList.get(i).name + "\n";
            System.out.print(msgLog);
        }
        System.out.println();
        
    }

    private String getIpAddress() {
        String ip = "";
        try {
            Enumeration<NetworkInterface> enumNetworkInterfaces = NetworkInterface
                .getNetworkInterfaces();
            while (enumNetworkInterfaces.hasMoreElements()) {
                NetworkInterface networkInterface = enumNetworkInterfaces
                    .nextElement();
                Enumeration<InetAddress> enumInetAddress = networkInterface
                    .getInetAddresses();
                while (enumInetAddress.hasMoreElements()) {
                    InetAddress inetAddress = enumInetAddress.nextElement();

                    if (inetAddress.isSiteLocalAddress()) {
                        ip += "SiteLocalAddress: "
                            + inetAddress.getHostAddress() + "\n";
                    }

                }

            }

        } catch (SocketException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            ip += "Something Wrong! " + e.toString() + "\n";
        }

        return ip;
    }

    class ChatClient {

        String name;
        Socket socket;
        ConnectThread chatThread;

    }

}

download filesDownload the files.