Mokus
Mokus

Reputation: 10400

Unable to start the service

I am trying to start a service

Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
        bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
        startActivity(gattServiceIntent);

However I am getting the following message

07-14 20:58:13.296: E/AndroidRuntime(21311): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.rcfun.blecar/com.rcfun.blecar.util.BluetoothLeService}; have you declared this activity in your AndroidManifest.xml?

I tried to declare as follow

    <service
        android:name=".BluetoothLeService"
        android:enabled="true">            
    </service>   

and

    <service
        android:name="com.rcfun.blecar.util.BluetoothLeService"
        android:enabled="true">            
    </service>  

But both declaration gives the same error as I mentioned above.

Upvotes: 0

Views: 102

Answers (2)

VVB
VVB

Reputation: 7641

Try this :

bindService(new Intent(this,BluetoothLeService.class),mServiceConnection,Context.BIND_AUTO_CREATE);

Upvotes: 0

Dave Morrissey
Dave Morrissey

Reputation: 4411

Replace startActivity(gattServiceIntent); with startService(gattServiceIntent);.

Upvotes: 2

Related Questions