Wednesday, 19 March 2014

The All Important setDeleteIntent for Notifications

My app, BreakFree, notifies the user in case of any event like using the phone for a total of 1 hour, or launching a particular app 15 times or more, etc. Now, there is also an option in my app wherein the user gets to see his phone addiction score as a persistent notification. This is updated at every unlock. My problem here was that I did not want to overwrite the event notification with the addiction score notification till the user clears the event notification himself. 

Now, call me dumb, but for the love of God I found it impossible to find documentation on how to detect the user clearing the notification. After a lot of searching I found the missing link. Actually there are two. setDeleteIntent and setContentIntent.

Here is how I coded the solution:

1) In my function which updates my notifications, I created two pendingIntents, one two be called when the user deletes my notification (swiping it, or using the Clear All button). And the second to be called when the user clicks the notification. Both call the same receiver class (NotificationReceiver), but with different Extras. Pay particular attention to the flags for the Pending Intent.

//create pending intent to be called when user deletes the notification
Intent notiDeleted = new Intent(ctx, NotificationReceiver.class);
notiDeleted.putExtra(ctx.getString(R.string.noti_deleted), true);
PendingIntent notiDeletedIntent = PendingIntent.getBroadcast(ctx, 0, notiDeleted, 0);
   
//create pending intent to be called when user clicks the notification
Intent notiClicked = new Intent(ctx, NotificationReceiver.class);
notiClicked.putExtra(ctx.getString(R.string.noti_clicked), true);
PendingIntent notiClickedIntent = PendingIntent.getBroadcast(ctx, 1, notiClicked, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);


2) I then created a SharedPreference flag saying that the notification is still present in the notification tray. This flag tells my code not to show the second notification.

//create a flag that an event noti is being shown
spEdit.putBoolean(ctx.getString(R.string.SPCEventNotiVisible), true);
spEdit.commit();

3) Build the notification. Use the setDeleteIntent and setContentIntent.
// build notification
NotificationCompat.Builder nb = new NotificationCompat.Builder(ctx);
nb.setSmallIcon(R.drawable.ic_jump_outline);
nb.setContentIntent(notiClickedIntent);
nb.setDeleteIntent(notiDeletedIntent);
nb.setAutoCancel(true);

Notification bfN = nb.build();

4) Next we create our receiver class.
public class NotificationDeleteReceiver extends BroadcastReceiver{

@Override
public void onReceive(Context context, Intent intent) {

  //make flag to noti not shown
  SharedPreferences spObj =
  context.getSharedPreferences(context.getString(R.string.SPPrevSetting), 0);
  SharedPreferences.Editor spEdit = spObj.edit();
  spEdit.putBoolean(context.getString(R.string.SPCEventNotiVisible), false);
  spEdit.commit();

  //if called from user click then show app
  if(intent.getExtras().containsKey(context.getString(R.string.noti_clicked))){
Intent i = new Intent(context, MainScreen.class);
        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |            Intent.FLAG_ACTIVITY_CLEAR_TOP | 
        Intent.FLAG_ACTIVITY_SINGLE_TOP);                
i.putExtra(context.getString(R.string.noti_on_click),                              intent.getExtras().getString(context.getString(R.string.noti_on_click)));
context.startActivity(i);
}
  }

}

As you can the receiver changes the SharedPreference flag to false regardless of whether the notification was cleared or clicked. It then checks the extras and if the notification was clicked it then opens up the app.

Hope this helps you guys.

Monday, 10 February 2014

What was Google Thinking When They Did This?

Yeah, I'm talking about the totally ridiculous 'Rate this app to get recommendations' gig by Google.

So here is what happened to me the other day. I open up Play Store, and I get the Rate this app... thingy and its asking me to rate an app I uninstalled about 6 months ago. Now I download about an app a day, and I have no freekin idea about that app, was it good? Did it crash on me? Did I get bored of it? Umm.. no.. no idea. But I still want the recommendations.. So being the good guy I am I give it 5 stars and proceed. BUT.. the problem is we are not living in a world filled with good guys, I am sure many would have just given it a one star rating and moved on. Yeah, check out this link by androidpolice.

This is where my problem lies as a developer. I have a stickiness ratio of about 40% on my apps, which means 60% of my installs result in uninstalls. And imagine google asking these guys to rate my app.. I mean c'mon some of them may not even have used my app. 

I see what Google's trying to do here, they want apps rated which helps them in ranking the apps, fair enough. NO.. not fair. Cause a majority of these ratings are not even legit. They've been given under the temptation of getting more recommendations like my app. 

All I can do is hope that there are more good guys like me out there.

Saturday, 8 February 2014

Reducing Image Sizes to Reduce the Size of Your apk

Wanted to write a quick blog post on this wonderful tool I found called ImageOptim. So the apk size of my app, BreakFree, had gone to 7mb. Which I was not very comfortable with. Many users, being on limited data, are fussy about downloading apps over 2-3 mb. My app was clearly well over. 

One of the things I had never considered before was reducing the size of my images. And the most easiest ways I found was by using this tool called ImageOptim. You can get it at imageoptim.com. Its super easy to use, unlike the other tools I explored. And it does a decent job with the images as well.

All my images are .pngs saved mostly on full compression out of GIMP. By processing them through ImageOptim I got an average reduction of about 16%-17% on my file sizes. I managed to reduce my apk size to 5.5mb. A far cry from the ideal 3 mb, but at least its better than 7mb.

Sunday, 2 February 2014

Why the Mobile App Business Needs Immediate Intervention

The other day I read an article on why the mobile app business is NOT the business to be in. Some parts of the article made sense, and even though I want to rubbish the article, there is one part of me that believes in what the author wrote. 

We usually only want to believe and hear the rosy stories. The 18 year old who made millions by selling an app he developed in high school, or about the guy who moved from a one bedroom apartment to a mansion in Florida. Lets face it, the chances of that happening to us is zilch. Not because we cannot make decent apps, but because the app stores are now overcrowded. Yeah, theres tons of apps out there. And the worse part is most of these apps are free. I mean think about it, if there is a butt ugly app out there, doing 70% of the things that your charming app does, and is free, your out of the race man. No man in his right state of mind is going to pay 99 cents for your wonderful app if there is a free substitute out there.

Now its because of this precise reason that the ridiculous concept of in-app purchasing has blossomed. We cannot charge for our apps, but we have to make money, so what do we do? We give our apps away for free, in the hope that maybe 1% of the folks who download our app, purchase a part of it. The concept of in-app purchases is just so flawed. If it were to happen in retail, we would have Walmart selling free shampoos without caps. If you want to walk out with a cap on your shampoo, please pay 99 cents. 

This is where I think Google and Apple should intervene. If they want to make a business out of their app stores, want healthy competition, then they better do something. I don't know what, I really don't have a solution, but I hope they find one fast.

Monday, 20 January 2014

BreakFree is Officially Published

Hello peoples. Its been two days since the launch of BreakFree, and the response has been decent. I've collected about 75 odd downloads with seven people rating it (all 5 stars as yet, woohoo). I would have obviously liked the download numbers to be better, don't we all hope for our apps going viral, but this is still ok. Considering this is a beta launch and I did not marketing whatsoever, except for posting comments in some articles and Youtube videos.

I have already made two updates due to the bugs found by users. I have also created quick and dirty website (it seriously was quick, about 3 hrs to learn Wordpress and create the website). You can check it out by clicking the 'BreakFree' link under 'My Apps'.

My strategy is to wait till I get about 500 downloads, after which I start my heavy duty promotions. I am still coming up with a plan for the promotion piece. Will share that you as well.

Attaching a few screenshots of the app. You can get more detail by visting the website or the Google Play Store page.

Have fun.





Saturday, 18 January 2014

BreakFree App Launched for Android

Just wanted to send a quick note out to tell you that I have launched my third app, BreakFree. The app is meant to help users use their smartphones mote constructively. The app monitors your phone usage, gives you an 'Addiction Score' and also gives you tools to help you be away from your phone.

Give the app a try, I am sure it will help you save time for the important things in life :)

Get it on Google Play


Wednesday, 8 January 2014

December Income Report

My App Download and Income report for the month of December. 

My sales for December are almost identical to the November sales. Not surprising at all, considering I didn't put in any updates for my apps. I've just been working on my upcoming app 'BreakFree', which should be out (hopefully) this month. 



Fuel Buddy



Downloads in December: 3363
Admob Revenue: $123.06
eCPM: $0.73
In-app: 32 Orders, $51






Pingy Pong



Downloads in November: 1304
Admob Revenue: $21.22
eCPM: $0.36