我的应用程序中有一个奇怪的错误,有时在下面的代码中出现 NULL 异常(是的,有时听起来很奇怪!!!)
请看一看
String appId = preferences.getString(ProjectConstants.IMEI_NO, null);
if (appId == null) {
// Here i am getting exception:
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
appId = manager.getDeviceId();
preferences.edit().putString(ProjectConstants.IMEI_NO, appId);
}
日志猫
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:278)
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856) Caused by: java.lang.NullPointerException
at com.homeshop18.service.GSONfunctions.getGSONfromURL(GSONfunctions.java:115)
at com.homeshop18.ui.myorder.MyOrdersFragment$DownloadMyOrders.doInBackground(MyOrdersFragment.java:92)
at com.homeshop18.ui.myorder.MyOrdersFragment$DownloadMyOrders.doInBackground(MyOrdersFragment.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:264)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) ... 5 more
任何帮助将不胜感激.. :D