*> The line I have bolded is where the error seems to be happening and the
log file shows the following. *
Perhaps... If you look further in the stack trace (beyond what you posted)
you should see a "caused by" line... The caused by line will give you a file
name and line number that is the actual cause of the NullPointerException.

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Thu, Mar 17, 2011 at 2:14 PM, David Williams <
[email protected]> wrote:

>  Seems to be that the issue is located some where in the following code,
> located at the end of the email.  Not sure why it would work every other
> time the app gets launched and then not every subsequent time.
> The line I have bolded is where the error seems to be happening and the log
> file shows the following.  Would appreciate any pointers.
>
> 03-17 20:06:37.415: WARN/System.err(301): java.lang.NullPointerException
> 03-17 20:06:37.445: WARN/System.err(301):     at
> org.json.JSONTokener.nextCleanInternal(JSONTokener.java:112)
> 03-17 20:06:37.485: WARN/System.err(301):     at
> org.json.JSONTokener.nextValue(JSONTokener.java:90)
> 03-17 20:06:37.515: WARN/System.err(301):     at
> org.json.JSONObject.<init>(JSONObject.java:154)
> 03-17 20:06:37.515: WARN/System.err(301):     at
> org.json.JSONObject.<init>(JSONObject.java:171)
> 03-17 20:06:37.535: WARN/System.err(301):     at
> com.dtwconsulting.golfcaddietrial.GolfCaddie$initialiseServer.doInBackground(GolfCaddie.java:114)
> 03-17 20:06:37.556: WARN/System.err(301):     at
> com.dtwconsulting.golfcaddietrial.GolfCaddie$initialiseServer.doInBackground(GolfCaddie.java:1)
> 03-17 20:06:37.565: WARN/System.err(301):     at
> android.os.AsyncTask$2.call(AsyncTask.java:185)
> 03-17 20:06:37.585: WARN/System.err(301):     at
> java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
> 03-17 20:06:37.585: WARN/System.err(301):     at
> java.util.concurrent.FutureTask.run(FutureTask.java:137)
> 03-17 20:06:37.615: WARN/System.err(301):     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
> 03-17 20:06:37.645: WARN/System.err(301):     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
> 03-17 20:06:37.645: WARN/System.err(301):     at
> java.lang.Thread.run(Thread.java:1096)
>
>
> private class initialiseServer extends AsyncTask<Void, Integer, Boolean> {
>          protected void onPreExecute(){
>              initDialog = ProgressDialog.show(GolfCaddie.this, "",
>                      "Initializing. Please wait...", true);
>          }
>
>          protected Boolean doInBackground(Void...voids) {
>              Boolean expired = false;
>              String installType = "";
>               String retInit = "";
>               String initExpDate = "";
>               SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd");
>
>              // Let's get the device ID
>              TelephonyManager mTelephonyMgr =
> (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
>              String imei = mTelephonyMgr.getDeviceId();
>
>              // Now, let's check the application to see if we have the
> trial or full version.
>              if
> (getApplication().getPackageName().equals("com.dtwconsulting.golfcaddietrial")){
>                  installType = "trial";
>              } else {
>                  installType = "full";
>              }
>              try {
>                  // Construct data
>                  String data = "code=" + imei + "&installtype=" +
> installType + "&apikey=" + GlobalVars.GCAPI_KEY + "&platform=" +
> GlobalVars.PLATFORM;
>
>                  // Send data
>                  URL url = new URL(GlobalVars.HOST_WAP + "initialize.php?"
> + data);
>                  URLConnection conn = url.openConnection();
>
>                  // Get the response
>                  BufferedReader rd = new BufferedReader(new
> InputStreamReader(conn.getInputStream()));
>
>                  retInit = rd.readLine();
>                  *JSONObject initLine = new JSONObject(retInit);*
>                  Number initErr = initLine.getInt("errcode");
>                  initExpDate = initLine.getString("expiredate");
>                  rd.close();
>              } catch (Exception e) {
>                  e.printStackTrace();
>              }
>              Date expDate = null;
>              Date today = new Date();
>
>              try {
>                  expDate = df.parse(initExpDate);
>              } catch (ParseException e) {
>                  // TODO Auto-generated catch block
>                  e.printStackTrace();
>              }
>              if (expDate.before(today)){
>               if (installType.equals("trial")) {
>                  // Trial has expired
>                  expired = true;
>               }
>              }
>             else{
>                 expireDate = df.format(expDate);
>             }
>              return expired;
>          }
>
>          protected void onPostExecute(Boolean result) {
>              initDialog.dismiss();
>              if (result){
>                  AlertDialog.Builder builder = new
> AlertDialog.Builder(GolfCaddie.this);
>                     builder.setMessage("Your Golf Caddie trial has
> expired." )
>                            .setCancelable(false)
>                            .setPositiveButton("Ok", new
> DialogInterface.OnClickListener() {
>                                public void onClick(DialogInterface dialog,
> int id) {
>                                    GolfCaddie.this.finish();
>                                }
>                            });
>                     AlertDialog alert = builder.create();
>                     builder.show();
>              }
>              else{
>                  checkInstall();
>              }
>          }
>      }
>  --
> ------------------------------
>
> David Williams
> Check out our WebOS mobile phone app for the Palm Pre and Pixi:
>  <http://www.dtw-consulting.com/GolfCaddie>   Golf 
> Caddie<http://www.dtw-consulting.com/GolfCaddie>| Golf
> Caddie Forum <http://www.dtw-consulting.com/GolfCaddie/forum> | Golf
> Caddie FAQ <http://www.dtw-consulting.com/GolfCaddie/faq.html> by
> DTW-Consulting, Inc.
>
>
>   --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

<<GClogo.png>>

Reply via email to