Saturday, April 23, 2016

What user do on your app - use AppSee

AppSee is best analytics tool to know what your user are doing on app. It will give video of user actions.

https://dashboard.appsee.com/login

Thursday, April 14, 2016

android alarm best practice

- reset at boot complete
- use RTC_WAKEUP

pending alarms use:
adb shell dumpsys alarm

sample code:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<receiver    android:name="<receiver path in code>"    android:enabled="true"    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>
public class RestartPhoneReceiver extends BroadcastReceiver {
    @Override    public void onReceive(Context context, Intent intent) {
        try {
            common.Log("In boot receive event");
            Long morningTime=common.GetMillisecondsTime("08:05");
            Calendar cal = Calendar.getInstance();
            cal.setTimeZone(TimeZone.getTimeZone("Asia/Calcutta"));
            cal.setTimeInMillis(morningTime);
            cal.add(Calendar.DAY_OF_MONTH,1);
            cal.add(Calendar.MINUTE_OF_HOUR,<random number>);

            long calendarTIme=cal.getTimeInMillis();

            Intent alarmintent = new Intent(context, MyAlarmService.class);

            PendingIntent sender = PendingIntent.getBroadcast(context, 12345,alarmintent, PendingIntent.FLAG_UPDATE_CURRENT|Intent.FILL_IN_DATA);
            //6*60*60*1000            AlarmManager am = (AlarmManager) context.getSystemService(context.ALARM_SERVICE);
            am.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), 24*60*60*1000, sender);
        } catch (Exception e)
        {
            //        }
    }
}