2
I’m trying to replace a code I made using thead by services ,but when I create the service it doesn’t start (doesn’t start any service method) and searching the net vi some solutions that said it could be in "manifest.xml" but the changes I made didn’t solve the problem.
My question is : Where am I going wrong?
The manifesto:
<permission android:name="android.permission.FLASHLIGHT"
    android:permissionGroup="android.permission-group.HARDWARE_CONTROLS"
    android:protectionLevel="normal" />
<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:screenOrientation="portrait"
    android:theme="@style/Metronome.Theme" >
    <activity
        android:name=".view.MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Metronome.Main.Theme" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <service android:name=".Compasso"/>
    </activity>
    <activity
        android:name=".view.ConfiguracoesActivity"
        android:label="@string/title_activity_configuracoes"
        android:screenOrientation="portrait" >
    </activity>
</application>
This is the Activity method I try to start the service:
public void executar(){
        FrontConversor conversor = new FrontConversor();
        conversor.setVibracao(true);
        conversor.setFlash(false);
        conversor.setTempoMinutos(npTimer.getValue());
        conversor.setFrequenciaBPM(npBPM.getValue());
        conversor.setQuantidadeBatidas(npQntBatidas.getValue());
        conversor.createSomById(getIdSom(), this);
        conversor.createFiguraRitmicaById(npValorBase.getValue());
        //executer.preExecuter(conversor, this); // preparar
        startService(new Intent(this,Compasso.class)); // executar
}
And this is a part of the extend service class (bar class):
public class Compasso extends Service{
...
 @Override
 public int onStartCommand(Intent intent, int flags, int startId) {
    Log.d("MARK","Service iniciado");
        double frequenciaSegundos = this.conversorBPM(this.frequenciaBPM); // 2bps
        double Delay = 1000 / frequenciaSegundos; // 0.5s
        int tempoMiliSegundos = (this.tempoMinutos * 60 * 1000); // (60000 milisegundos)
        double quantidadeCiclo = tempoMiliSegundos / (this.batidasMaximo * Delay);
        this.stopNow = false;
        try {
            // Iniciando ciclo de batidas
            loopSound(Delay, quantidadeCiclo);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } finally {
            this.stopMetronomo();
        }
        return START_STICKY;
    }
...
    @Override
    public IBinder onBind(Intent intent) {
         return null;
    }
}
So I think it should return when the service start will be an error (nullpointerException) but not even error it returns.
Thank you in advance.
In the manifest,
<service>is not at the same level of<activity>(not inside her)?– danguilherme