Sunday, March 15, 2015

Introducing Tracksum

Hello,

Recently we launched one other product which is android application. It's called "Tracksum". As the name suggests this is the application used for tracking.

Tracksum is a very efficient tool to let you know about your vehicles driving and tracking. Providing you accurate drove distance, time versus location update and auto check in and check out at your key locations and giving you stoppage times. Really handy tool for logistic companies to have on their vehicles.

As mentioned above you can define routes for vehicles and define key locations. App will notify you as soon as your vehicle enters into that key location and exits for that location. You will also get detailed tracking on map with all the locations marked on map and entry and exit time reports. This way you can accurately track your vehicle and you will have all the information regarding that trip.


As you can see above you can see detailed tracking on map with all the key locations. With this application you get a decent admin panel where you can create vehicles, create routes, define key locations and assign routes to locations.  Also in admin panel you can see all types of reports like entry, exit reports and can see tracking. 

If you want this app you can download it from following link and contact us, we will setup login for your admin panel. For more information contact us.

https://play.google.com/store/apps/details?id=com.tracksum.vehicletrack&hl=en

In short this is an awesome application for any business who want to automate their tracking system. If you want this app for your organizations or want to know more about it, kindly contact us. Following are our contact details.

Vibhay Vaidya : +919920465555
Rinkal Shah : +919898171728

Also drop us an email on following email ids.

info@novustouch.com
info@thedesignshop.co.in

Thank you.



Tuesday, March 3, 2015

Cocoa OSX NSTextField Allow Only Integer Value

Hello,

Recently I was working on MAC OSX application where we have a view with some textfields. Where in few textfields where only numeric values are allowed. In this blog I will explain how to do this.

I used NSNumberFormatter for that. First you have to create a class which extends NSNumberFormatter.

Go to your .m file and add new interface.

@interface OnlyIntegerValueFormatter : NSNumberFormatter


@end

Now implement this interface in same file.

@implementation OnlyIntegerValueFormatter

- (BOOL)isPartialStringValid:(NSString*)partialString newEditingString:(NSString**)newString errorDescription:(NSString**)error
{
    if([partialString length] == 0) {
        return YES;
    }
    
    NSScanner* scanner = [NSScanner scannerWithString:partialString];
    
    if(!([scanner scanInt:0] && [scanner isAtEnd])) {
        NSBeep();
        return NO;
    }
    
    return YES;
}

@end

That's it. Now create instance of OnlyIntegerValueFormatter and assign it to NSTextField. 

OnlyIntegerValueFormatter *formatter = [[OnlyIntegerValueFormatter alloc] init];
[self.onlyIntegerTextField setFormatter:formatter];

That's it. Now if you try to type characters in the textfield, it won't allow it. 

Tuesday, February 24, 2015

Android Obtain Crash Data of Application Remotely

Recently in one my project we distributed APKs to some people to test applications and we got a complain that APP is crashing. While on our side app was not crashing and it was working fine. We were not sure what could be possible reason of crash.  As they were running app from APK we sent in mail so there is no way they can report to Play Store. So we added our own solution to get stack trace on server from the app. In this blog I am going o explain how to do this.

First we added custom exception handler class. Here is that class. 

package com.myapp.app;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.lang.Thread.UncaughtExceptionHandler;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;

import android.util.Log;

public class CustomExceptionHandler implements UncaughtExceptionHandler {

    private UncaughtExceptionHandler defaultUEH;
    private String url;
    public CustomExceptionHandler(String url) {
        this.url = url;
        this.defaultUEH = Thread.getDefaultUncaughtExceptionHandler();
    }

    public void uncaughtException(Thread t, Throwable e) {
        Calendar c = Calendar.getInstance();
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String timestamp = df.format(c.getTime());
        final Writer result = new StringWriter();
        final PrintWriter printWriter = new PrintWriter(result);
        String stacktrace = result.toString();
        printWriter.close();
        String time = timestamp + ".stacktrace";
        if (url != null) {
            sendToServer(stacktrace, time);
        }

        defaultUEH.uncaughtException(t, e);
    }

    private void sendToServer(String stacktrace, String time) {
        Log.v("stacktrace","stacktrace");
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        List nvps = new ArrayList();
        nvps.add(new BasicNameValuePair("time", time));
        nvps.add(new BasicNameValuePair("stacktrace", stacktrace));
        try {
            httpPost.setEntity(
                    new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
            httpClient.execute(httpPost);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

As you can see in above class we have added Class with name CustomExceptionHandler which implements UncaughtExceptionHandler. The constructor is expecting server URL. This is your custom server URL where you want to log stack trace. As you can see in above code we have uncaughtException function which is logging stack trace to server by calling function sendToServer with HTTP POST request. Now We have to add this class as exception handler. This you can do in onCreate of your activity.

Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler(
     null, "http://yourloggingurl));

As you can see in above code we are setting default exception handler for thread and passing the URL, you have to replace your own URL instead of yourloggingurl. That's it and your app will send complete stack trace on crash to server. Here is the PHP code on server to get data and write a file if you need.

<?php
    $time = $_POST['time'];
    $stacktrace = $_POST['stacktrace'] ;
    file_put_contents($filename, $stacktrace . "\n", FILE_APPEND);
?>

As yo can see in above codes you are getting stack trace and writing to a file. Make sure you have write permission on directory.