0

I am developing app for Android Nexus Player(TV). I am trying to start a service on button click, but service is not starting. Am i missing anything? This service is working on android tablet perfectly. But not on Nexus Player( TV Box).

Code on Button click:

Intent serviceIntent = new Intent(this, MyService.class);
ComponentName componentName = startService(serviceIntent);

if(componentName == null)
    showLogText("Service does not start"); 

Manifest declaration

<service android:name="com.hdmi.MyService"/>

onStartCommand was implemented like this

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        systemAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        if(acceptThread != null && acceptThread.isAlive())
            acceptThread.cancel();
        else {
            acceptThread = new AcceptThread();
            acceptThread.start();
            Log.i("Server", "Starting");
        }

        return super.onStartCommand(intent, flags, startId);
    }
saa
  • 1,538
  • 2
  • 17
  • 35

1 Answers1

1

Try this

@Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        systemAudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        if(acceptThread != null && acceptThread.isAlive())
            acceptThread.cancel();
        else {
            acceptThread = new AcceptThread();
            acceptThread.start();
            Log.i("Server", "Starting");
        }

        //return super.onStartCommand(intent, flags, startId);
        return Service.START_STICKY;
    }