title: Creating a service that can be start/stop from ADB. (vibrate on service start)
body: <p>I want to rotate the phone from ADB command (or even tcp/ip socket).
  So I want to have a service I can start and stop from remote PC.</p>
  
  <p>I don't know what am I doing wrong, when I "run" the application from studio I don't see the service in the service list:
  adb shell service list</p>
  
  <p>MyService.java:</p>
  
  <pre><code>package com.example.vibrate;
  
  import android.app.Service;
  import android.content.Intent;
  import android.os.IBinder;
  import android.os.Vibrator;
  
  public class MyService extends Service {
      Vibrator vibrator;
      public MyService() {
      }
  
      @Override
      public IBinder onBind(Intent intent) {
          // TODO: Return the communication channel to the service.
          throw new UnsupportedOperationException("Not yet implemented");
      }
  
      @Override
      public void onCreate() {
          super.onCreate();
  
          vibrator = (Vibrator)getSystemService(VIBRATOR_SERVICE);
  
      }
  
      @Override
      public int onStartCommand(Intent intent, int flags, int startId) {
  
          vibrator.vibrate(2000);
          return super.onStartCommand(intent, flags, startId);
  
      }
  }
  </code></pre>
  
  <p>AndroidManifest.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.vibrate"&gt;
  
      &lt;uses-permission android:name="android.permission.VIBRATE"/&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
  
          &lt;service
              android:name=".MyService"
              android:enabled="true"
              android:exported="true"&gt;
          &lt;/service&gt;
      &lt;/application&gt;
  
  
  
  &lt;/manifest&gt;
  </code></pre>