title: Can I merge two class in two java file into one?
body: <p>The following code works well, but I think it is too complex.</p>
  
  <p><strong>SmsBroadcastReceiver.java</strong></p>
  
  <pre><code>public class SmsBroadcastReceiver extends BroadcastReceiver{
  
      private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
  
      public SmsBroadcastReceiver(){
      }
  
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
          if (intent != null &amp;&amp; intent.getAction() != null &amp;&amp; ACTION.compareToIgnoreCase(intent.getAction()) == 0) {
  
              PublicPar.myContext=context;            
              Object[] pduArray = (Object[]) intent.getExtras().get("pdus");
              SmsMessage[] messages = new SmsMessage[pduArray.length];
  
              for (int i = 0; i &lt; pduArray.length; i++) {
                  messages[i] = SmsMessage.createFromPdu((byte[]) pduArray[i]);               
                  MSms myMSms=new MSms();     
                  Intent msgIntent = new Intent(context,SmsInternetServer.class); 
                  HandleSMS.SetIntentOrGetFromIntent(msgIntent, myMSms, true);
                  context.startService(msgIntent);
              }
          } 
      }
  
  }
  </code></pre>
  
  <p><strong>SmsInternetServer.java</strong></p>
  
  <pre><code>public class SmsInternetServer extends IntentService {
  
      public SmsInternetServer() {
          super("SmsInternetServer");     
      }
  
      @Override
      protected void onHandleIntent(Intent intent) {
          // TODO Auto-generated method stub
          HandleSMS.HandleReceivedSMS(intent);        
      }
  
  }
  </code></pre>
  
  <p>so I merge the two class in two java file into one, is it OK? and is there more simple way to simplify code? such as anonymous class.</p>
  
  <p><strong>SmsBroadcastReceiver.java</strong></p>
  
  <pre><code>public class SmsBroadcastReceiver extends BroadcastReceiver{
  
      private static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";
  
      public SmsBroadcastReceiver(){
      }
  
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
          if (intent != null &amp;&amp; intent.getAction() != null &amp;&amp; ACTION.compareToIgnoreCase(intent.getAction()) == 0) {
  
              PublicPar.myContext=context;            
              Object[] pduArray = (Object[]) intent.getExtras().get("pdus");
              SmsMessage[] messages = new SmsMessage[pduArray.length];
  
              for (int i = 0; i &lt; pduArray.length; i++) {
                  messages[i] = SmsMessage.createFromPdu((byte[]) pduArray[i]);               
                  MSms myMSms=new MSms();     
                  Intent msgIntent = new Intent(context,SmsInternetServer.class); 
                  HandleSMS.SetIntentOrGetFromIntent(msgIntent, myMSms, true);
                  context.startService(msgIntent);
              }
          } 
      }
  
         //inner class
         class SmsInternetServer extends IntentService {
  
         public SmsInternetServer() {
          super("SmsInternetServer");     
         }
  
         @Override
         protected void onHandleIntent(Intent intent) {
          // TODO Auto-generated method stub
          HandleSMS.HandleReceivedSMS(intent);        
         }
  
         }
  
  }
  </code></pre>