Konuyu Oyla:
  • Derecelendirme: 0/5 - 0 oy
  • 1
  • 2
  • 3
  • 4
  • 5
Müzik Çalmıyor Sebebi Nedir
#1
Question 
package hatirlatici.tubitak.com.hatrlatc;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.IBinder;
import android.support.annotation.Nullable;
import android.util.Log;
import android.widget.Toast;

import java.security.Provider;

public class MuzikOynatici extends Service {
   MediaPlayer sarki;
   int baslat;
   boolean calisiyorsa;

   @Nullable
   @Override
   public IBinder onBind(Intent intent) {
       return null;
   }


   @Override
   public int onStartCommand(Intent intent, int flags, int baslat) {
       Log.i("LocalService", "Received start id " + baslat + ": " + intent);

       String state = intent.getExtras().getString("extra");

       Log.e("Zil Sesi ",state);
       assert state != null;
       switch (state) {
           case "Alarm Aktif":
               baslat = 1;
               break;
           case "Alarm Kapandı":
               baslat = 0;
               Log.e("Başlama ID'si: ",state);
               break;
           default:
               baslat = 0;
               break;
       }


       if(!this.calisiyorsa && baslat == 1) {
           sarki = MediaPlayer.create(this, R.raw.muzik);
       }
       else if (!this.calisiyorsa && baslat == 0){

           Log.e("if there was not sound ", " and you want end");



           this.calisiyorsa = false;

           this.baslat = 0;



       }



       else if (this.calisiyorsa && baslat == 1){

           Log.e("if there is sound ", " and you want start");



           this.calisiyorsa = true;

           this.baslat = 0;



       }

       else {

           Log.e("if there is sound ", " and you want end");



           sarki.stop();

           sarki.reset();



           this.calisiyorsa = false;

           this.baslat = 0;

       }

           Log.e("if there was not sound ", " and you want start");




           Log.e("MyActivity", "In the service");




       return START_NOT_STICKY;
   };

   @Override
   public void onDestroy() {


       // Tell the user we stopped.
       Toast.makeText(this, "on Destroy called", Toast.LENGTH_SHORT).show();
   }


}
Bul
Cevapla
#2
Merhaba,
Bu şekilde hata tespiti yapabilmemiz maalesef mümkün değildir.
Android studio debug özelliği ile projenizi çalıştırıp müzik çalmamasının sebebini tespit etmeyi deneyebilirsiniz. Ya da proje özel değilse ve paylaşırsanız inceleyip sorunu tespit etmeye çalışabiliriz.
İyi çalışmalar.
Cevapla


Hızlı Menü:


Konuyu Okuyanlar: 1 Ziyaretçi