Gaurav Chandra Gaurav Chandra   August 8, 2016

Android captures 97% of the market share in India.

I recently got to know that Android has captured 97% of the market share in India. Source. Out of all the smartphone users in India, they are using some version of the Android app. This means that you definitely need to target Android users first when you are making a mobile app for your business.

iOS users are the ones from whom you will generate more revenue as they are the ones who spend money on apps as opposed to Adnroid users. Reason is that the iOS users are from an income group which is higher than the average Android user base. Android users are more used to free apps as the play store is cluttered with sub standard free apps.

If you have an idea which would mean a stand alone mobile app, you do need to target iOS users also but Android should be the first OS which you should target as it is easier to test and fast to update the app than iOS.

Get in touch with me to know more.

Gaurav Chandra Gaurav Chandra   June 15, 2016

Create persistent notification on Android using NativeScript

I was experimenting with some background tasks in nativescript for android and I found that one way to ensure that your android app will always run even when it is in background is to use a persistent notification. So, I was able to create this using the following code:

NativeScript Code:

main.js

var APP = require('application');
var utils = require("utils/utils");
var application = APP.android;

exports.navigatingTo =  function (args) {
    var page = args.object;

    var randomCode = new java.util.Random().nextInt();//to be used later to associate the 2 things
        var intent = new android.content.Intent(application.foregroundActivity, com.tns.NativeScriptActivity.class);
    var pendingIntent = android.app.PendingIntent.getActivity(application.foregroundActivity, randomCode, intent, android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK);
    var builder = new android.app.Notification.Builder(application.foregroundActivity);
    builder.setDefaults(0);
    builder.setContentTitle("NativeScript Running");
    builder.setContentText("This notification cannot be cleared");
    builder.setContentIntent(pendingIntent);
    builder.setTicker("Persistent Notification");
    builder.setSmallIcon(application.nativeApp.getApplicationInfo().icon);
    builder.setPriority(android.app.Notification.PRIORITY_HIGH);
    builder.setOngoing(true);//this tells the OS that the notification is persistant
    var notification = builder.build();
    var notificationManger = utils.ad.getApplicationContext().getSystemService(android.content.Context.NOTIFICATION_SERVICE);
    notificationManger.notify(randomCode, notification);
};

and voila, you have persistant notification. Ofcourse this can be better managed but now you know how to create a persistent notification. Enjoy.