package io.akessler.elixircounter;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent overlayService = new Intent(this, OverlayService.class);
        startService(overlayService);
        finish();
    }
}

@@ -29,16 +29,41 @@
 unter;%0A%0A
+import android.Manifest;%0A
 import a
@@ -104,238 +104,1510 @@
 oid.
-os.Bundle;%0Aimport android.support.v7.app.AppCompatActivity;%0A%0Apublic class MainActivity extends AppCompatActivity %7B%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);
+content.pm.PackageManager;%0Aimport android.os.Bundle;%0Aimport android.support.v4.app.ActivityCompat;%0Aimport android.support.v4.content.ContextCompat;%0Aimport android.support.v7.app.AppCompatActivity;%0A%0Apublic class MainActivity extends AppCompatActivity %7B%0A%0A    /* Used to handle permission request */%0A    private static final int PERMISSIONS_REQUEST_RECORD_AUDIO = 1;%0A%0A    @Override%0A    protected void onCreate(Bundle savedInstanceState) %7B%0A        super.onCreate(savedInstanceState);%0A%0A        // Check if user has given permission to record audio%0A        int permissionCheck = ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.RECORD_AUDIO);%0A        if (permissionCheck != PackageManager.PERMISSION_GRANTED) %7B%0A            ActivityCompat.requestPermissions(this, new String%5B%5D%7BManifest.permission.RECORD_AUDIO%7D, PERMISSIONS_REQUEST_RECORD_AUDIO);%0A            return;%0A        %7D%0A%0A        startOverlayService();%0A    %7D%0A%0A    @Override%0A    public void onRequestPermissionsResult(int requestCode,%0A                                           String%5B%5D permissions, int%5B%5D grantResults) %7B%0A        super.onRequestPermissionsResult(requestCode, permissions, grantResults);%0A%0A        if (requestCode == PERMISSIONS_REQUEST_RECORD_AUDIO) %7B%0A            if (grantResults.length %3E 0 && grantResults%5B0%5D == PackageManager.PERMISSION_GRANTED) %7B%0A                startOverlayService();%0A            %7D else %7B%0A                finish();%0A            %7D%0A        %7D%0A    %7D%0A%0A    private void startOverlayService() %7B
 %0A   

Add permissions check to allow recording audio with mic