title: How to open dialog in onHandleIntent() method of an IntentService class
body: <p>I want to open a custom dialog in  <code>onHandleIntent()</code> method of an <code>IntentService</code> class, but when I write code for showing Dialog in this method it shows error</p>
  <p><code>The method findViewById(int) is undefined for the type MyAlarmService</code></p>
  <p>Can anyone suggest me how to solve this issue?</p>
  <p>Code I have used:</p>
  <pre><code>public class MyAlarmService extends IntentService { 
  public void onCreate() {
      super.onCreate();
  }
  
  public MyAlarmService() {
      super(&quot;MyAlarmService&quot;);
  }
  
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      super.onStartCommand(intent, startId, startId);
      Toast.makeText(this, &quot;MyAlarmService.onStart()&quot;, Toast.LENGTH_LONG).show();
      return START_STICKY;
  }
              
  @SuppressWarnings(&quot;static-access&quot;)
  @Override
  protected void onHandleIntent(Intent intent) {
      final Dialog alarmDialog = new Dialog(MyAlarmService.this);
      alarmDialog .requestWindowFeature(alarmDialog.getWindow().FEATURE_NO_TITLE);
      alarmDialog .getWindow().setBackgroundDrawable(new ColorDrawable(0));
  
      Context mContext = getApplicationContext();
      LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
      View layout = inflater.inflate(R.layout.clear_all_warning_dialog, (ViewGroup) findViewById(R.id.layout_warning_dialog));
      
      TextView dialogTitile = (TextView) layout.findViewById(R.id.dialog_title_text);
      
      TextView dialogDesc = (TextView) layout.findViewById(R.id.dialog_desc_text);
      
      Button buttonYes = (Button) layout.findViewById(R.id.button_yes);               
      
      Button buttonNo = (Button) layout.findViewById(R.id.button_no);             
  
      alarmDialog.setContentView(layout);
      alarmDialog.show();
      
      buttonYes.setOnClickListener(new OnClickListener() {                    
          @Override
          public void onClick(View v) {
              alarmDialog.dismiss();
          }
      }); 
      buttonNo.setOnClickListener(new OnClickListener() {                 
          @Override
          public void onClick(View v) {
              alarmDialog.dismiss();
          }
      }); 
  }
  }
  </code></pre>