title: how to create a service to interact with a content provider?
body: <pre><code>    String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
  
      Cursor mCallCursor = getContentResolver().query(
              CallLog.Calls.CONTENT_URI, null, CallLog.Calls.TYPE + "=?",
              new String[] { String.valueOf(CallLog.Calls.MISSED_TYPE) },
              strOrder);
  
      // get start of cursor
      if (mCallCursor.moveToFirst()) {
  
          // loop through cursor
          do {
  
              mCall = mCallCursor.getString(mCallCursor
                      .getColumnIndex(CallLog.Calls.NUMBER));
  
              Toast.makeText(getBaseContext(), mCall + " ",
                      Toast.LENGTH_SHORT).show();
  
          } while (mCallCursor.moveToNext());
  
      }
  </code></pre>
  
  <p>My app needs to run in the background using a service, but I don't know how to accomplish that. I created a class to access the call logs content provider, specifically the missed calls, so that when a certain number failed to reach the user for 3 consecutive tries, it will set the ringer on if the phone is silent.</p>