title: My app not able to detect the network.
body: <p>I would like to be able to detect the sim operator name and return a code if it is found. Please help me. below are the two methods from my code </p>
  
  <p>//first method to detect sim Operator </p>
  
  <pre><code>private void simOperatorName() {
  // TODO Auto-generated method stub
  //operator gotten
  final TelephonyManager telephonyManager = 
  (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
  networkName =  telephonyManager.getSimOperatorName().toUpperCase();
  
  if (networkName != null ){
  network =  networkName;
  
  }else {
  
   Log.d("LEE", "NETWORK OF THE SIM WAS NOT FOUND");          Toast.makeText(getApplicationContext(), 
  "Please Network Not Found", Toast.LENGTH_LONG).show();
  }
  }
  </code></pre>
  
  <p>// second method </p>
  
  <pre><code>private String network() {
  // TODO Auto-generated method stub
  simOperatorName();
  
  try {
  if(network == "MTN"){
  code = "*125*";
  }else if (network == "VODAFONE") {
  code= "*122*";
  }else if (network == "TIGO") {
  code = "*842*";
  }else if (network == "GLO") {
  code = "*123*";
  }else if (network == "AIRTEL") {
  code = "*134*";
  } catch (Exception e) {
  // TODO: handle exception
  Log.d("LEE", "Network not Found");
  Toast.makeText(getApplicationContext(),"Please Code otFound",Toast.LENGTH_LONG).show();
  }return code;
  }
  </code></pre>