In the logCat, he suggests to use FLAG_ACTIVITY_NEW_TASK
flag , so try the following:
if (primaryCode == 6) {
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Log.d(TAG, primaryCode + " Greating is command");
}