Sunday, August 30, 2015

Windows Dev Center short notes on Account type, locations and fees

There are two types of developer accounts, 1. Individual accounts 2. Company accounts Both of these types of accounts give access to the 

Below are some of the differences between Individual and Company account 

1. Individual account is restricted from using certain app capabilities
2. Cost approx 19USD, which varies according to the region

Where are company account is capable of below 

1, Requires verification through Symantec
2. Greater access to app capabilities 
3. Ability to submit verification of EV status
4. Requires the company to be recognized in the region or country 
5. Costs approx 99USD. 

There are main three capabilties

enterpriseAuthentication : uses Windows credentials to access corporate intranet. This is typically used in line of business app that connects to servers within an enterprise. (Typically, we don’t need this capability for generic communication over internet. 

sharedUserCertificates: Enables an app to access software and hardware certificates such as certificates stored on the smart card. This is typically used for financial or enterprise apps that require a smart card for authentication. 

documentsLibrary: Allows programmatic access to users documents, filtered to the type associations declared in the package manifest. (Typically, apps that use file picker for acessing files don’t need this permission) Note that apps targeting Windows Phone 8.1 or earlier cannot use this documentsLibrary capability.   


references:
https://dev.windows.com/en-us/getstarted

C++ apps and Windows Apps - A Comparison

If one is coming from the background of Windows desktop programming in C++, we will probably find that some aspects of Windows Store App and Windows Phone app programming are familiar, but other aspects require some learning. 

Whats same? 

- We can use STL, the CRT (with some exceptions) and any other C++ library as long as the code does not attempt to call windows functions that are not accessible from the Windows Runtime Environment 

- If one is accustomed to visual designers, we can still use the designer built into Microsoft Visual studio or we can use more full featured Blend for Visual Studio. IF accustomed to code by Hand, then can use XAML. 

- One will be still developing apps for windows operating system types and own custom types. 

- One will be still using profile debugger VS debugger and other tools 

- One will be still creating apps that are compiled to run on native machine code by the windows runtime. C++ apps don’t run in managed environement

Then Whats new in Windows App development? 

- The design principles of Windows Apps and Windows Phone apps are entirely different. Windows borders, labels, dialog boxes are de-emphasized. 
- The separation between UI and core program is much clearer in Windows Universal app than in Win32 or MFC app. Developer will be using XAML to define the entire UI
- Developer will be programming against a new, easy to navigate object oriented API, the windows Runtime, although on Windows devices Win32 is still available for some functionality
- One will use C++/CX to consume and create Windows Runtime Objects. C++/CX enables C++ exception handling, delegate events and Automatic reference count of dynamically creating objects. When we use C++/CX, the details of the underlying COM and Windows architecture are hidden from the app code. 
- When an app is compiled into a package, that also contains meta data about the types that the app contains, the resource that it uses and the capabilities that it require (file access, internet access, camera access etc) 
- In the windows store and Windows Phone Store, the app is verified by a certification process and made discoverable to millions of potential customers. 



References:  
https://dev.windows.com/en-us/getstarted

Saturday, August 29, 2015

Windows Apps a sneak peak

Below are few sections in the Windows App development page that intended to help developing Windows Apps. Windows 10 Universal Windows Platform helps to create apps with just one API set and one package to reach all Windows 10 devices. PCs, tablets and Phone. 

To set up, Visual Studio Community 2015 gives a developer everything we need to start developing apps. And its free! 

IF registered as an app developer, this account will let publish the app to the Windows Store. 

there are many languages which can be chosen to start developing the applications. for e.g. 

C# and XAML 
Javascript with HTML 
C++ with XAML 

There are many featured learning materials such as 

For Absolute beginners 

C# Fundamentals for Absolute beginners 
VB Fundamentals for Absolute beginners 
Javascript fundamentals for Absolute beginners 
HTML5 and CCS3 for Absolute beginners 

There are many video tutorials in the Microsoft Virtual academy video series as they detail What windows 10 and UWP offers for Developers 

There are some examples as it would be good sometimes to refer those. 


references:
https://dev.windows.com/samples

https://msdn.microsoft.com/library/windows/apps/dn894631.aspx

Monday, August 24, 2015

MKMapView animating positions on a route

Below code animates a marker on the map from source to destination. 

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    CLLocationCoordinate2D centerCoord = { 37.774929, -122.419416 };
    [self.mapView setCenterCoordinate:centerCoord zoomLevel:3.0 animated:NO];
    
    CLLocationCoordinate2D sanFrancisco = { 37.774929, -122.419416 };
    CLLocationCoordinate2D newYork = { 40.714353, -74.005973 };
    CLLocationCoordinate2D pointsArc[] = { sanFrancisco, newYork };
    
    thePlane = [[MKPointAnnotation alloc] init];
    thePlane.coordinate = sanFrancisco;
    thePlane.title = @"Plane";
    [self.mapView addAnnotation:thePlane];
    geodesic = [MKGeodesicPolyline polylineWithCoordinates:&pointsArc[0]
                                                     count:2];
    planePositionIndex = 0;
    [self performSelector:@selector(updatePlanePosition) withObject:nil afterDelay:2.0];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)updatePlanePosition
{
    planePositionIndex = planePositionIndex + 50;
    if (planePositionIndex >= geodesic.pointCount)
    {
        return;
    }
    MKMapPoint nextMapPoint = geodesic.points[planePositionIndex];
    //convert MKMapPoint to CLLocationCoordinate2D...
    CLLocationCoordinate2D nextCoord = MKCoordinateForMapPoint(nextMapPoint);
    //update the plane's coordinate...
    thePlane.coordinate = nextCoord;
    //schedule the next update...
    [self performSelector:@selector(updatePlanePosition) withObject:nil afterDelay:0.5];

}


references:
http://stackoverflow.com/questions/22504822/animate-a-visual-element-along-an-arc-in-mapkit/22506771#22506771

iOS MKMapView Setting Zoom level

It was surprising initially that MKMapView doesn't really have a built in method to set the zoom level of the map. Having all the time spent using the Google Map Services MapView, this was little embarrassing. However, searching around a bit, revealed some good solutions, which it looked to be good one is in the link in the references.

The concept works by spanning the map. Below is the overall idea of spanning.

 // convert center coordiate to pixel space
    double centerPixelX = [self longitudeToPixelSpaceX:centerCoordinate.longitude];
    double centerPixelY = [self latitudeToPixelSpaceY:centerCoordinate.latitude];
    
    // determine the scale value from the zoom level
    NSInteger zoomExponent = 20 - zoomLevel;
    double zoomScale = pow(2, zoomExponent);
    
    // scale the map’s size in pixel space
    CGSize mapSizeInPixels = mapView.bounds.size;
    double scaledMapWidth = mapSizeInPixels.width * zoomScale;
    double scaledMapHeight = mapSizeInPixels.height * zoomScale;
    
    // figure out the position of the top-left pixel
    double topLeftPixelX = centerPixelX - (scaledMapWidth / 2);
    double topLeftPixelY = centerPixelY - (scaledMapHeight / 2);
    
    // find delta between left and right longitudes
    CLLocationDegrees minLng = [self pixelSpaceXToLongitude:topLeftPixelX];
    CLLocationDegrees maxLng = [self pixelSpaceXToLongitude:topLeftPixelX + scaledMapWidth];
    CLLocationDegrees longitudeDelta = maxLng - minLng;
    
    // find delta between top and bottom latitudes
    CLLocationDegrees minLat = [self pixelSpaceYToLatitude:topLeftPixelY];
    CLLocationDegrees maxLat = [self pixelSpaceYToLatitude:topLeftPixelY + scaledMapHeight];
    CLLocationDegrees latitudeDelta = -1 * (maxLat - minLat);
    
    // create and return the lat/lng span

    MKCoordinateSpan span = MKCoordinateSpanMake(latitudeDelta, longitudeDelta);

References:
http://troybrant.net/blog/2010/01/set-the-zoom-level-of-an-mkmapview/

Google Drive APIs

Drive Android API is a native API that conforms to the standard best practices and coding conventions. 
It is improvement over the generated client API, simplifying many common tasks associated with using Drive service on mobile devices.
The API automatically handles the complex tasks such as Synching and offline access. 

These APIs are part of Google play services API. 

Below is an API Overview for this API set 

Files are represented using the DriveFile interface. folder are by DriveFolder. Both share common super interface DriveResource, which contains DriveId. 
The DriveId is the unique Identifier for all the files and folders. 

The API also includes a package for querying for files based on meta data attributes, such as title. 

Resource Metadata : MetaData for resource is encapsulated in the MetaData class that contains all details about a file or folder including the title, the MIME type, 
and whether the file is editable, starred or trashed. The MetaData is fetched for a DriveResource by calling the DriveResourece.updateMetaData method. 

Files: Files can be fetched programmatically by the DriveApi.getFile method or by allowing the user to select a file using a file selector activity created with the 
OpenFileActivityBuilder. The file contains a reference to the contents of the file, encapsultated in the DriveContents class, which provides access to read and write the 
underlying the data.

Folders: Folders have additional helpers which simplify the various operations. These include creating a file or folder inside a folder. DriveFolder.createFolder, DriveFolder.createFile and listing or querying the children of a folder DriveFolder.listChildren, DriveFolder.queryChildren. 

Activity Builders: Activity Builders are two helper classes that implement UI components to simplify common tasks associated with opening and creating files. 

CreateFileActivityBuilder help to quickly create a file, set inside a folder title, contents and set meta data. 

OpenFileActivityBuilder help to easily open a file selected by the user. This class displays a UI to let the user navigate and select from a list of files that match the specified MIME types. 

Queries allow to search for specific files or folders based on their metadata attributes such as title. Queries can be represented by Query class and can be constructed using the Query.Builder class.

References:

Sunday, August 23, 2015

IPv6 support Basics

ARIN has hosted a site that facilitate discussions and sharing information on IPv6 topics and issues. 

Inorder to know the needs of IPv6, we need to know the depletion of IPv4. When IPv4 became the Internet standard, the 4.2 billion possible IP addresses were never intended to house a global internet. It was in 1981, there were only a limited number of computers that needs to be connected to the internet. Nowadays, in addition to every computer, nearly every single cellular telephone and gaming console is connected to the internet. According to the Number resource organization, only 10% of the space is remained in the IANA (Intenet assigned Numbers Authority) free pool as of beginning of 2010.

Why IPv6? The solution to the IPv4 depletion is simple. Developing a more robust numbering system will allow far more IP addresses. The IPv6 holds 340,282,366,920,938,463,374,607,431,768,211,456 IP addresses. 

references:

Google ProtoBuf - quick Overview

Protocol Buffers are flexible, efficient, automated mechanism for serializing structured data. This is smaller, faster, simpler. A developer define how he want the data to be structured once. then on, he can use special generated source code to easily write and read the structured data to and from a variety of data streams and using variety of languages. 

Now the question is how do they work? 

A developer specifies how he want the information he is serializing to be structured by defining protocol buffer message types in .proto files. Each protocol buffer message is a small logical record information, containing a series of name-value pairs. Below is a sample of a .proto file that defines a message containing information about a person. 

message Person 
{
required string name = 1 ; 
required int32 id = 2;
optional string email = 3; 
enum PhoneType
{
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber 
{
required string number = 1;
optional PhoneType type = 2 [default = HOME];
}

repeated PhoneNumber phone = 4;

Here, Person is called a protocol buffer message. Once the Protocol buffer message is defined, it needs to be run through buffer compiler of the application’s language on the photo file to generate the data access classes. These provide sample accessors for each filed like name as well as methods to serialize, parse the whole structure to/from raw bytes. 

Person person;
person.set_name(“John”);
person.set_id(1234);
person.SerializeToOStream(person);

References:

Building a Custom Cordova plugin for iOS


When looked for some sample to do this, found the article given in the reference section. In this example, when a text is sent from the browser, it is written to native file system using the FileWriter iOS class. 

First step is to create a cordova project. the command is as below. 

$ cordova create . CustomPlugin CustomPlugin
Creating a new cordova project.

Then added the iOS platform using the below command 

$ sudo cordova platform add ios 

Then ran the project and could see the cordova splash screen. 

To develop a custom plugin, added the feature tag to the config.xml file like below right under the tag 

name="FileWriter">
        name="ios-package" value="FileWriter" />
   


Below was the header definition of FileWriter header file. 

#import

@interface FileWriter : CDVPlugin

// This will return the file contents in a JSON object via the getFileContents utility method
- (void) cordovaGetFileContents:(CDVInvokedUrlCommand *)command;

// This will accept a String and call setFileContents to persist the String on to disk
- (void) cordovaSetFileContents:(CDVInvokedUrlCommand *)command;

#pragma mark - Util_Methods

// Pure native code to persist data
- (void) setFileContents;

// Native code to load data from disk and return the String.
- (NSString *) getFileContents;

@end



References:

Mobile Wallet - a birds eye view


Mobile Wallets use NFC chips insider the smartphones and tablets to transmit payment information. When customer ready to pay using mobile wallet, customers enter the PIN and selects the payment account they wish to use along with any special offers or any customer reward programs they want to apply. At the time of payment, they simply tap their device to an enabled payment terminal, and the payment information is transmitted. 

Currently there are two notable mobile wallet providers that have the potential to dominate the space in the near term - Google Wallet and Softcard. Google wallet has opened its acceptance to all major payment brands and try to gain wider adoption. 

Soft card is a joint venture between AT&T, T-Mobile, Verizon, Softcard’s carrier backing is a key factor in differentiating it from other mobile wallet offerings. 

To Adopt this mode of payment, 

All businesses should be prepared to and acquire a merchant service account or update their hardware to accept these payment types. Small businesses may face some challenges in adopting new technologies.  Banks give Future Proof Banking terminals to ease this problem such as devices ingenico iCT250. 



References:

Wednesday, August 19, 2015

C Unions and Struct - A recap

The main difference between unions and struct is that union members overlay the memory of each other so that the size of the union is one, while struct 
members are laid out one after each other (with optional padding in between). Also a union is large enough to contain all its members, and have an alignment 
that fits all members For e.g. if int can only be stored at 2 byte address and is 2 bytes wide, and long can only be stored at 2 bytes address and is 4 bytes 
long. 

With this above, the following union could have size of 4 

union test
{
int a, 
long b
};

Both union and struct can have padding at the end, but not at the beginning. 

Writing to a struct changes only the value of the member written to. Writing to a member of union will render the value of all other members invalid. 

Another explanation is that struct is a record structure. each element in the struct allocates new space. 

struct  foobar
{
int foo;
long bar;
double baz;
}

this allocates at least sizeof(int) + sizeof(long) + sizeof(double) 

while the below, 

union foobar 
{
int foo;
long bar;
double baz;
}

this union allocates one chunk of memory and gives it 3 aliases. so, sizeof (footer) >= max (sizeof(int), sizeof(long), sizeof(double)) with possibility of some additional alignments. 

The best usecase is below 

Imagine an imaginary protocol like below 

struct packetHeader
{
int sourceaddress;
int destaddress;
int messagetype;
union request{
char fourcc[4];
int requestnumber;
}
}

In this protocol, based on the messageType, it can be either a request number or a 4 character code, but not both. In short, unions allow same storage to be used for multiple data types. 


References:

Monday, August 17, 2015

Android WebView

Showing a page in WebView is really simple. Below code will enable to do that

WebView graphWebView = (WebView)findViewById(R.id.webView);
    if(graphWebView != null)
    {
        WebSettings webSettings = graphWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        graphWebView.setWebViewClient(new AppWebViewClient());
        graphWebView.loadUrl("http://google.com");

    }

It is important to set the WebView client because that actually decides whether the web page to be loaded in the web view or should be outside. Little odd as we think it should have been other way.

private class AppWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (Uri.parse(url).getHost().equals("www.google.com")) {
                // This is my web site, so do not override; let my WebView load the page
                return false;
            }
            // Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }
    }

also to note, we should have setJavaScriptEnabled(true) inorder to enable the javascript code to be working on this page. 

We can also load webpages from file system that can inturn also hit the servers. 

File lFile = new File(Environment.getExternalStorageDirectory() + "/" + "graph.html");
            Log.v(LOG_TAG,"File object is :"+lFile);
            Log.v(LOG_TAG,"File Path is :"+lFile.getAbsolutePath());
            graphWebView.loadUrl("file:///" + lFile.getAbsolutePath());

Here it is very important to have the prefix file:/// otherwise, the loading wont work. 

References
http://developer.android.com/guide/webapps/webview.html

Friday, August 14, 2015

Android BugAnalytics SDK

The account set up was easy. Just had to give the email ID and name and company details. 

For integrating the SDK into the app, just had to download the SDK jar file and then include in the application lib folder and using project dependency manager added this to the project as file dependency. 

Below is a screenshot of the console 




References:

Tuesday, August 11, 2015

Jade Framework for HTML development

Jade is a template language for faster web development. This is the default template engine in node express framework. 
Jade has been inpired by another template language called HAML. Jade also shares same philosophy as HAML and they are below 

- Markup should be beautiful 
- Mark up should be DRY (Don’t Repeat Yourself) 
- Markup should be well intended 
- The HTML structure should be clear 

Below is a sample using Jade 

doctype html
html
title hello jade
body
h1 this is headding 
p this is paragraph 

Like can be seen, there is no HTML tag that appears in this sample. 

There are two ways of start using Jade 

1. Use an online cloud editor 
A cloud tool such as http://jsbin.com provides a cloud based tool 

2. Set up jade on the computer. 
npm install jade —global 
this installs jade on the computer. To check if jade is installed properly, below command can be used 

jade —-version  

jade -P hello.jade 

converts the jade file into html 

Jade as a template language, also provides options to declare variables, and iterators. 


references:
http://jade-lang.com/tutorial/

MoSync for mobile app development


Mosync is an open source SDK which is a rich cross platform development environment that makes it easy to develop apps for all major Mobile platforms 

One can develop app for various pltforms using C/C++ or HTML5/Javascrpt or a combination to create hybrid apps. 

Mosync supports iOS, Android 2.x - 4.x, Windows phone, Symbian S60, Java and Moibile Linux platforms 

- Apps can be developed in C / c++ or HTML5 
- It has been actively being deveolped since 2004
- Wormhole techonolgy offers developers with web view functions 
- It is based on eclipse development environment 
- Wormhole technolgoy enables HTML5 to ta;l to the underlying native layer. 

The SDK includes Eclipse plugin for development. Below given is a sample application 

#incldue

using namespace MAUtils; 

class MyMoblet : public Moblet
{
public :
MyMoblet()
{
masetColor(#FFFFFF);
maDrawText(“helloworld”);
}

void keyPressedEvent(int keycode, int nativecode)
{
}

};

extern “C” int MAMain()
{
MyMoblet moblet; 
MAMoblet::run(&moblet);
return 0;
}


references:
http://www.mosync.com/

Friday, August 7, 2015

Android A better way to get Application Context anywhere in the app

Context reference is much needed everywhere in the application. Without this, it is going to be tough to do much of the processing such as registering receivers, posting notification etc. We can set the context when Activity starts to some static location, but the problem is that when the OS restarts the app, the Application context will be lost, this will be causing NPEs. Below code will give better way to get the context.
   
    import android.app.Application;
    import android.content.Context;
    import android.util.Log;
    
    public class MyApplication extends Application {
        
        private static Application sApplication;
        
        private static final String LOG_TAG = "EOMeApp";
        public static Application getApplication() {
            return sApplication;
        }
        
        public static Context getContext() {
            return getApplication().getApplicationContext();
        }
        
        @Override
        public void onCreate() {
            super.onCreate();
            Log.v(LOG_TAG,"On create of application");
            sApplication = this;
        }

    }

In the manifest file, in the Application tag, define the below 


android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name=".MyApplication">

references:
http://stackoverflow.com/questions/2002288/static-way-to-get-context-on-android

Saturday, August 1, 2015

iOS UISplitView Basics

When a project is created with MasterDetailView template, internally it uses the UISplitViewController to achieve this. To learn internal workings of a UISplitViewController, thought to go through the tutorial at the link in references. Since the Xcode was version 6 at this writing, the Xcode options looked to be different. Below are the few simple steps to get the UISplitViewCotnroller into project

1. Create New Application as Single View Application (In the latest Xcode, there is no Empty Application template. so)
2. The story board by default will have a View Controller, drag and drop UISplitView Controller from the object box and delete the already existing view controller
3. Remember to set the Entry point as the Split view controller. Run and see in both iPad and iPhone 

When added the UISplitViewController, it added a bunch of things, mainly the below ones

1. A SplitViewController => To this, the Main View Controller and a Navigation Controller is added 
2. The Navigation controller hosts the TableViewController for navigational purposes 

These individual controllers can be customized by providing sub class and then setting the sub classes as the class names in the Storyboard Scene properties for individual scenes. 

From iOS 8.0, below call back is called whenever the popover appears on top of the main view detialed view controller to reveal the left view controller

- (void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode NS_AVAILABLE_IOS(8_0)
{
    NSLog(@"-- Will change to display mode is called --");
}

Though the concept is much useful in iPad, the iPhone part of experience is not so good. IF user need to go to the left view controller, the Detail view controller is completely removed from the scene. It is not similar to how a Left navigation list similar to Facebook where that can be created using view controller containment mechanism. 

Some of the screenshots are below 

iPad 



iPhone 6 Plus

iPhone 6



references: