Tuesday, February 16, 2016

Android watch programming - Overview


    Using Android wearables, you can write applications for Android TV, Watch and glass applications - this article focuses on Android variables for SmartWatch. 
Since Wearables is built on top of Android most of the core features in Android works on Android watch as well. Using android Watch API you can create applicatins for different watch sizes such as round dial, or a square Dial Watch. Apart from creating the watch face you can also create notifications, synchronize data with the watch - send and receive data. 
The notifications that comes for the apps in the mobile is also received by the watch. If you close the message on one device, the message gets removed on the other device as well. 

 What can you do using an Android watch

  • Your phone notifications such as meeting, traffic update, weather update, music, reminders are automatically synched with Android watch.
  • You can control actions on your notifications / pages – such as open the meeting on the meeting notification or play/pause your music app from your watch.
  • Use voice commands to ask questions, initiate app, send / reply to an email, create meetings right from your watch – just like you do using your phone.

What can you do using Android wear API:

  •  Make applications for round and square structured watches.
  • Create new watch faces
  •  Act on wearable notifications
  •  Use voice message as an action.
  • Build Notification messages.
  • Send and receive data from/to the phone/ tablet using the Data layer API and the message API. This allows you to communicate with your phone wirelessly over Bluetooth
  • Detect location data on watches.



Basic Design principles:

  • Performance in loading the watch page: This should not take more than a couple of seconds as the user is not going to hold the wrist to see the page if it takes more than a couple of seconds. Hence avoid rich data and concentrate on the data that is going to be shown.
  • Do not cram the screen with too much information.
  •  Keep the android screen type in mind – round or square and design accordingly.
  •   Keep notifications to the minimum in case of watch. Show only important and required information in the watch. Use suggest notifications.
  • Omit too much text – use icons to convey what you want. For example you can display a cloud with snowy icon to show the weather status as snowy instead of the text “snowy”.
  • \Provide confirmation notifications whenever required. The user should know what he did what happened to the action he performed.
  •  Since wearable devices run on Bluetooth low energy devices, developers need to ensure they design the applications in such a way to not affect the battery. You have to consider the battery closely when 

            - you design watch faces and the data in them, how often they get refreshed
            - you use location based features.
  

Thursday, February 11, 2016

Getting started with Android watch programming


This article explains you how to create a project in android studio, and run them using the emulator. 

Steps:
1.       Create a new wearable project using the wizard in Android studio, Select “Phone and tablet” and “Watch” in the project type.

2.       You will find 2 projects in the android project – Mobile and wear.

a.       Mobile project should be installed in the mobile or tablet.
b.      Wear project should be installed in the watch.



3.       Since android watch comes in both round and square forms, we have 2 separate layout files –
app:rectLayout="@layout/rect_activity_main"
app:roundLayout="@layout/round_activity_main"

Only one of the layout is rendered depending upon the watch you choose.


4.       If you go to the design view of the the activity files, you will be able to choose the layout type and see the project you have created.

Round view layout (or) Square view





5.       Choose an Android virtual device which you want to run.
This again comes in different formats.




Create the AVD you want.




6.       If you have not installed the system image for the selected android version, you might need to download it first in your PC.


7.       You can now run the project you have created in the emulator


 




Tuesday, February 9, 2016

Blockchain - How it works

While the detailed functionality of how Blockchain works depends on the individual framework / tool you choose for implementing block chain.

Blockchain mainly consists of 2 components – the P2P network and the distributed database.

·         P2P network: A mechanism used by different computers in the network to communicate the change in the database. This change to the state may be called as transaction.
 o    This network consists of different nodes which are connected to each other and is decentralized from the other node.
o    If any node fails or shuts down, no problem, we still have the data and the processing happens on the other available node.
o    Since the data is available is available on any node, we cannot clearly tell from where the data is coming from, which is good since you cannot censor based on where the data is or who sent it.

·         Database: This is the distributed database which is present in different nodes in the network and it stores the entire history of the data.

o    As and when the users create transactions, the transactions are are added to the pool of pending transactions. The transactions are collected as blocks, and when it creates the block, the block stores the transactions in the same order in which it retrieves. A signature is placed on the block which is modified every time someone changes the transaction or tamper the transaction in the block. In this case, the block notifies all the other nodes that the tampering has happened.
o    The block also maintains a pointer to the previous block to maintain the history of changes happened in the Blockchain.

When a new message (transaction) is sent to the block chain, the following happens.

§  The message is sent to the nodes in the Blockchain. The message may be sent to any node(s). Each nodes sends the message to the neighbouring nodes.
§  Quickly the message gets distributed to different nodes in the network.
§  The Actual database which is distributed across different nodes.
§  The nodes in the Blockchain process the transaction and communicates that it is successful or failed.

How the nodes are processed, how many nodes process the transactions, how the bidding works depends on the Blockchain platform you choose.
Since Bitcoin is an implementation of Blockchain, we can see how bitcoin works at a high level.
-          A wants to send 5$ to B.
-          Every user has his own private key to prove his identity and create a signature. A get’s B’s public key and creates a transaction and send it to the Blockchain using the wallet application. A wallet is an app (may be mobile app) which knows the user as it has the private key and knows how to send the transaction to the Blockchain.
-          Bitcoin requires the signature of the user to prove the user of the account. The signature is created based on the private key of the user and the transactional message.
-          These signatures cannot be copied and reused since the signatures are unique to each transaction.
-          As and when the transactions occur, the transactions are sent to the pool of pending transactions (blocks) which also maintains the order in which it receives the transaction. The transactions execute in the same order in which it is received.
-          The bit coin miners (or participants) choose a transaction from the pending pool and try to solve a mathematical problem which they use to bid for processing the transaction.
-          The miner then verifies if A has enough bitcoin to make a transaction to B.
-          When the bitcoin miner is then choosen and validates the transaction, a small % of bitcoin is rewarded for the processing. Finally B’s account is updated with A’s transaction amount.
-          If someone tries to tamper the B’s public key to a different public key, then the block signature is modified and other nodes are notified of the tampered activity. Thus the system works even if one node fails or not trustable or slow.

Blockchain technologies


The Blockchain implementation can be public or private depending upon the use case:
There are many Blockchain technologies that can be categorized under Blockchain 2.0 protocol projects such as NXT, Master coin, ethereum, Bitshares, Blocksign, Codius.
While most of the projects in the Blockchain technologies seem to be solving a problem for a particular use case or adding as a new feature, Ethereum takes a different approach.
Ethereum is a platform and a programming language that helps users to build decentralized applications. It is a general purpose crypto currency platform that can run all blockchains and protocols Each node in the network runs a full EVM (Ethereum virtual machine) for smart contract execution.

A smart contract is a program written by Blockchain developers and pushed to the Ethereum which gets deployed in multiple nodes for execution. This internally uses peer to peer protocol and libraries to exchange information between different nodes. Multiple nodes bid for running the process and executed the contract. The information is shared between other nodes. If a node is tampered, the other nodes in the network is aware of this change. 

Blockchain and startups

Following are some of the startups who are using blockchain. 
  1. Ethereum: Ethereum is a decentralized platform   that run exactly as programmed without any possibility of downtime, censorship, fraud or third-party interference. Ethereum also contains a programming language which developers can use to build their own Blockchain applications.

  2. 2.       tØ is a blockchain-based trading platform created by online retail giant Overstock which aims to revolutionise securities by making trade and settlement occur simultaneously using blockchain technology. 

    3.       OpenBazaar: Is a decentralized marketplace which tries to eliminate government and organizations that restricts free, censor transactions and get their own cut. 

    4.        Storj: Is a decentralized cloud storage service that stores data not in cloud servers, but in nodes using Blockchain technology and P2P protocols. Each file is shredded and encrypted and stored in different nodes and hence it is more secure. You can be sure that it is safe since the keys to read the file are in your pocket. The nodes participating in the network can earn more by renting their hard drive to store data, it’s like opening your own Hard drive hotel.  

    5.       Blockai: a Blockchain publishing platform which helps the authors of digital asset to create them, publish and claim ownership for the assets so that they can turn into monetizable assets. 

    6.       Lazooz: an attempt to implement real-time ridesharing, but without the company.

    7.       BlockCypher: helps developers to quickly build Blockchain applications using the framework webservices blockcypher provides. 

    8.       Filament: is trying to build the first decentralized IOT stack, which helps device to interact without a central server or authority. 

    9.       ShoCard: a virtual identity card platform which consumers use a mobile application which is built on top of Blockchain data layer. The shocard uses public/private key encryption and data hashing to store and exchange identity data. 

    10.   CloudPay: helps users to make mobile payments using Ethereum and digital currencies. 

Applications of Blockchain

Applications of Blockchain:

What can you do using Blockchain


  • Manage contracts in a smarter way by not depending upon one server or organization. With smart contracts, you can directly deal with your partners and store contracts and rules in blockchain network Smart contracts
  • Tracking products: You can track a product exactly where it originated from - say a food item can now be tracked where it was farmed from how it was maintained and this information can be stored in public.
  • Ownership details: You can store information like I am willing to buy your house for 1000$ on this date in block chain - it will be stored in this public ledger for everyone to see - you cannot go back and change this to 500$ or the date. 
  • Storing public records such as land & property titles, marriage certificates, death certificates, vehicle registrations, notarized documents etc.,
  • Identity: Identiy a person, thing by verifying data against the person. For example Onename.com is a Blockchain id registrar that links users and validate by using them using different ways – visit onename.com for more information. https://onename.com/deiveehan
  • Store identification records such as driver licences, ID cards, passports and voter registrations.
  • IOT – Internate of things:
    • Device to device transactions, for example the device such as television or washing machine can have its own identity and can make re-order, make transactions on its own. Who owns what device can be stored in Blockchain.
    •  Of course, Money transactions: Blockchain can help you in transferring money to another country as it will be faster and cheaper. With this technology it will be faster and cheaper. Bitcoin is already an implementation of Blockchain which helps users to transfer quickly without a middleman.

Some interesting links:

  • Lazooz – block chain based ride sharing platform.
  • Nasdaq share trade using Blockchain – read more
  • Smart contracts - youtube
  • IBM Adept’s POC demo shows how do they implement this technology to make devices do smart payments – View demo
  • Couple got married on Blockchain – read more
  • How block chain will change the real-estate market – Read more
  • Crowd funding using Blockchain: Blockchain based crowd funding: Blockchain-based crowdfunding is similar to traditional crowdfunding, however, collected funds are accounted for and tracked via a Blockchain – Read more



Blockchain - basics

A decentralized application is an application where the data required for processing is not owned by government or companies, but by individuals from different parts of the world, who get paid for lending their processing power to run those programs. 

Some of the main characteristics of a decentralized application include: 
  • Data may not be owned by a single company or an organization. 
  • Tamper proof: Once a transaction happens on a decentralized application, no one should be able to alter the data, and even if they do, it is not affected by that as many nodes does the processing. 
  • Data cannot be controlled, censored by a company or country. 
  • Data may not be limited to only monetary transactions, but can have any data such as ownership details. 
  • No need to trust a single node in the decentralized application. 


So what is Blockchain?

Blockchain is a technology that helps developers build decentralized applications – It allows two people or thing who does not know each other to trust and make transactions with each other. 

Blockchain is a distributed database that contains shared record of transactions that cannot be censored, tampered with, erased or duplicated. It’s a new way to store and record transactions. These transactions can be certificate of ownership of an item, bank's financial transaction, person's will information etc.

This distributed database is collaboratively maintained by peers on the network, called nodes. A node is a machine where the validation & processing happens. Individual nodes verify the sender and the transaction and approve them. This removes the need for a third party to intermediate. 

These nodes are stored in public which means this is not owned by a country or an organization. Users lend their processing power to process these data, in turn get their incentive for their processing power. 

The transactions involved can be anything from certificate of ownership of an item, bank's financial transaction, person's will information etc. 
  
Blockchain can be thought of as a public ledger which holds all important transactions that is stored in a distributed way. You can do a lot more with the Blockchain than exchange value. Once a transaction appears on the Blockchain, it is impossible to deny that it has happened. Hence it cannot be censored, tampered with, erased or duplicated. It is a technology that fundamentally influences the way trade ownership and trust has been functioning. 

Blockchain works well even when some of the operators are dishonest, some nodes run slowly or tampered. 

We will look more on block chain applications in the next article.