java me - Blackberry App is working on wi-fi but not on Packet Data/GPRS -


i have created blackberry application working fine on wi-fi. when turn off wi-fi , use mobile network not able run application. shows no internet connection available.

i had written these lines.

if (deviceinfo.issimulator())              {                 deviceinfo = deviceinfo.concat(";deviceside=true");             } 

here http connection class

import java.io.ioexception; import java.io.inputstream;  import javax.microedition.io.connector; import javax.microedition.io.httpconnection;  import net.rim.device.api.system.deviceinfo; import net.rim.device.api.system.radioinfo; import net.rim.device.api.ui.uiapplication; import net.rim.device.api.ui.component.dialog;  public class httpconn {     public string jsonresponse (string url)      {          string response = null;          httpconnection httpconnection = null;          inputstream instream = null;          int code;          stringbuffer stringbuffer = new stringbuffer();         string deviceinfo=url;         try          {              if (deviceinfo.issimulator())                 {                       deviceinfo = deviceinfo.concat(";deviceside=true");                                    }  /*           else if (wlaninfo.getwlanstate() == wlaninfo.wlan_state_connected)               {                   deviceinfo = ";interface=wifi";                }*/              else if ( (radioinfo.getactivewafs() & radioinfo.waf_wlan) != 0 && radioinfo.getsignallevel( radioinfo.waf_wlan ) != radioinfo.level_no_coverage )              {                       deviceinfo = deviceinfo.concat(";interface=wifi");               }  //           else if (wlaninfo.getwlanstate() == wlaninfo.wlan_state_connected)  //           { //                   deviceinfo = ";interface=wifi";//                   //           }             if ( (radioinfo.getactivewafs() & radioinfo.waf_wlan) != 0 && radioinfo.getsignallevel( radioinfo.waf_wlan ) != radioinfo.level_no_coverage )              {                       deviceinfo = deviceinfo.concat(";interface=wifi");                                   }  //           else if ((coverageinfo.getcoveragestatus() & coverageinfo.coverage_direct) == coverageinfo.coverage_direct)  //           { //                  string carrieruid = getcarrierbibsuid(); // //                  if (carrieruid == null)  //                  { //                      // has carrier coverage, not bibs. use carrier's tcp //                      // network // //                      deviceinfo = ";deviceside=true"; //                       //                  }  //                  else  //                  { //                      // otherwise, use uid construct valid carrier bibs //                      // request // //                      deviceinfo = ";deviceside=false;connectionuid="+carrieruid + ";connectiontype=mds-public"; //                       //                  } //              } //            //            // check mds connection instead (blackberry enterprise server) //           else if ((coverageinfo.getcoveragestatus() & coverageinfo.coverage_mds) == coverageinfo.coverage_mds)  //              { // //                  deviceinfo = ";deviceside=false"; //                   //              } // //              // if there no connection available abort avoid hassling user //              // unnecssarily. //              else if (coverageinfo.getcoveragestatus() == coverageinfo.coverage_none)  //              { //                  deviceinfo = "none"; //                   // //              } //              else //              { //                  deviceinfo=";deviceside=true"; //              }                     //if(coverageinfo.iscoveragesufficient(coverageinfo.coverage_direct,radioinfo.waf_wlan,false))  //            httpconnection = (httpconnection) connector.open(url+";interface=wifi", connector.read);             httpconnection = (httpconnection) connector.open(deviceinfo, connector.read);             httpconnection.setrequestmethod(httpconnection.get);               code = httpconnection.getresponsecode();                 if(code == httpconnection.http_ok)              {                 instream=httpconnection.openinputstream();                  int c;                   while((c=instream.read())!=-1)                  {                    stringbuffer.append((char)c);                  }                  response=stringbuffer.tostring();                  system.out.println("response getting server ================" + response);              }             // carrier network way connect?             // in theory, bases covered shouldn't reachable.but hey, in case ...          else              {                 uiapplication.getuiapplication().invokelater(new runnable()                  {                     public void run()                     {                                dialog.inform("connection error");                      }                  });              }         //          return deviceinfo;         }          catch (exception e)          {             system.out.println("caught exception in jsonresponse method"+e.getmessage());         }                  {         //      if (outputstream != null)          //      {          //          outputstream.close();          //      }                 if (instream != null)                  {                      try                      {                         instream.close();                     }                      catch (ioexception e)                      {                         // todo auto-generated catch block                         e.printstacktrace();                     }                  }                 if (httpconnection != null )                  {                      try                      {                         httpconnection.close();                     }                      catch (ioexception e)                      {                         // todo auto-generated catch block                         e.printstacktrace();                     }                  }          }         return response;      }  //  private synchronized static string getcarrierbibsuid() { //      servicerecord[] records = servicebook.getsb().getrecords(); //      int currentrecord; // //      (currentrecord = 0; currentrecord < records.length; currentrecord++) { //          if (records[currentrecord].getcid().tolowercase().equals("ippp")) { //              if (records[currentrecord].getname().tolowercase() //                      .indexof("bibs") >= 0) { //                  return records[currentrecord].getuid(); //              } //          } //      } // //      return null; //  }    } 

actually solution found.

java.io.ioexception:apn not specified . apn have set manually device wi-fi network?

http://m2m.icpdas.com/download/gtm-201_modem/manual/gprs_apn.pdf

http://www.faqspedia.com/list-of-all-indian-mobile-operators-access-point-names

refer link.

actually have set apn manually. provider.

i hope solution answer. lot support.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -