My app is running well on version below 5. But when i run it on Nexus 7 with version 5, it crashes with following error msg
12-02 18:24:01.941: E/StrictMode(14686): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
12-02 18:24:01.941: E/StrictMode(14686): java.lang.Throwable: Explicit termination method 'close' not called
12-02 18:24:01.941: E/StrictMode(14686): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
12-02 18:24:01.941: E/StrictMode(14686): at java.io.FileInputStream.<init>(FileInputStream.java:78)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.DiskLruCache.get(DiskLruCache.java:417)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.HttpResponseCache.get(HttpResponseCache.java:164)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:190)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
12-02 18:24:01.941: E/StrictMode(14686): at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:491)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.seekTo(MediaHTTPConnection.java:199)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.readAt(MediaHTTPConnection.java:315)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.native_readAt(Native Method)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.MediaHTTPConnection.readAt(MediaHTTPConnection.java:304)
12-02 18:24:01.941: E/StrictMode(14686): at android.media.IMediaHTTPConnection$Stub.onTransact(IMediaHTTPConnection.java:72)
Can anyone suggest solution for this.
Related
I keep getting this error:
12-02 17:34:55.648: E/AndroidRuntime(426): java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable
12-02 17:34:55.648: E/AndroidRuntime(426): at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:147)
12-02 17:34:55.648: E/AndroidRuntime(426): at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
12-02 17:34:55.648: E/AndroidRuntime(426): at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
I have tried unimporting and reimporting android.support.v7.ActionBarActivity
I hope someone can guide me to what the error is
My application has two tabhosts and both of them are necessary. I had to use tabhost instead of actionbar as my application need to be supported by the low-end android device.
Now, my FragmentActivity has two fragments and one of them has a ListView. The ListView loads fine but the application crashes with java.lang.StackOverflowError when I begin to scroll the list.
My layout for each row is very simple and as i told before it loads first time perfectly and crashes while its scrolled.
I put my logcat here.
12-02 15:14:26.929: E/AndroidRuntime(22971): FATAL EXCEPTION: GUI Thread
12-02 15:14:26.929: E/AndroidRuntime(22971): java.lang.StackOverflowError
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.graphics.Paint.measureText(Paint.java:1020)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.graphics.Paint.measureText(Paint.java:1057)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Styled.drawDirectionalRun(Styled.java:284)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Styled.measureText(Styled.java:447)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.measureText(Layout.java:1888)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.getLineMax(Layout.java:841)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.Layout.draw(Layout.java:386)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.text.BoringLayout.draw(BoringLayout.java:365)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.TextView.onDraw(TextView.java:4334)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6880)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.buildDrawingCache(View.java:6642)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.getDrawingCache(View.java:6428)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1571)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.AbsListView.dispatchDraw(AbsListView.java:1643)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.ListView.dispatchDraw(ListView.java:3207)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6986)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.AbsListView.draw(AbsListView.java:3021)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.support.v4.view.ViewPager.draw(ViewPager.java:2153)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.View.draw(View.java:6883)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.widget.FrameLayout.draw(FrameLayout.java:357)
12-02 15:14:26.929: E/AndroidRuntime(22971): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1964)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewRoot.draw(ViewRoot.java:1529)
12-02 15:14:26.929: E/AndroidRuntime(22971): at android.view.ViewRoot.performTra
I am working with gimbal proximity sdk. I am facing a strange error. The app is running perfectly fine on devices installed with pre-lollipop os versions. But when I try on lollipop devices I am getting an error at this line
contextContentConnector = ContextContentConnectorFactory.get(this);
Below is the LogCat message I am getting.
12-02 18:55:29.302: E/AndroidRuntime(20197): java.lang.AssertionError: impossible
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.Enum$1.create(Enum.java:45)
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.Enum$1.create(Enum.java:35)
12-02 18:55:29.302: E/AndroidRuntime(20197): at libcore.util.BasicLruCache.get(BasicLruCache.java:54)
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.Enum.getSharedConstants(Enum.java:211)
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.Enum.valueOf(Enum.java:191)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qsl.faar.service.location.c.a.a(SourceFile:3)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qsl.faar.service.location.e.a.e(SourceFile:93)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qsl.faar.service.location.e.a.a(SourceFile:45)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qsl.faar.service.location.d.<init>(SourceFile:65)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qsl.faar.service.location.g.<init>(SourceFile:225)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qsl.faar.service.b.a(SourceFile:188)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qualcommlabs.usercontext.a.d.a.a(SourceFile:28)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qualcommlabs.usercontext.ContextContentConnectorImpl.<init>(SourceFile:18)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qualcommlabs.usercontext.ContextContentConnectorFactory.get(SourceFile:18)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.la.gimbalapp.MainActivity.didArrive(MainActivity.java:132)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qrs.gimbalproximity.core.g.d.a(SourceFile:212)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.qrs.gimbalproximity.core.g.d$a.onReceive(SourceFile:58)
12-02 18:55:29.302: E/AndroidRuntime(20197): at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
12-02 18:55:29.302: E/AndroidRuntime(20197): at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
12-02 18:55:29.302: E/AndroidRuntime(20197): at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
12-02 18:55:29.302: E/AndroidRuntime(20197): at android.os.Handler.dispatchMessage(Handler.java:102)
12-02 18:55:29.302: E/AndroidRuntime(20197): at android.os.Looper.loop(Looper.java:135)
12-02 18:55:29.302: E/AndroidRuntime(20197): at android.app.ActivityThread.main(ActivityThread.java:5274)
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.reflect.Method.invoke(Native Method)
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.reflect.Method.invoke(Method.java:372)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
12-02 18:55:29.302: E/AndroidRuntime(20197): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
12-02 18:55:29.302: E/AndroidRuntime(20197): Caused by: java.lang.NoSuchMethodException: values []
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.Class.getMethod(Class.java:664)
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.Class.getDeclaredMethod(Class.java:626)
12-02 18:55:29.302: E/AndroidRuntime(20197): at java.lang.Enum$1.create(Enum.java:41)
12-02 18:55:29.302: E/AndroidRuntime(20197): ... 26 more
I've been having similar issues. I contacted Gimbal's customer support. Here is the answer I received:
Sorry for the inconvenience and thanks for your feedback. Currently Gimbal Android Proximity SDK doesn’t support Android 5.0(Lollipop). we would recommend developers to use Android 4.4.3 or 4.4.4 version to compile apps using Gimbal Android proximity SDK.
Also, we are very interested to have Gimbal proximity work with Android 5.0.0 and are working to support with an SDK. We will let you know as soon as update is available.
Thanks
The Gimbal Team
I have quite strange exception which appears when my app is resumed (after I switch to other apps and then return to mine) although it's not thrown always but only from time to time.
The part where exception is quite simple. I use ViewPager (v4) and have two dialog classes, first child DialogHelp:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState); [line 50]
second the parent PMDialogFragment (extends DialogFragment):
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
app = (PMApplication) getActivity().getApplication();
View view = inflater.inflate(layoutId, container); [line 50]
and below logcat:
12-02 00:48:04.532: E/AndroidRuntime(22292): FATAL EXCEPTION: main
12-02 00:48:04.532: E/AndroidRuntime(22292): java.lang.RuntimeException: Unable to start activity ComponentInfo{pitersoft.pitermemoflashcards/pitermemo.android.gui.activities.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x0
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1964)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1989)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.ActivityThread.access$600(ActivityThread.java:126)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1155)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.os.Handler.dispatchMessage(Handler.java:99)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.os.Looper.loop(Looper.java:137)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.ActivityThread.main(ActivityThread.java:4482)
12-02 00:48:04.532: E/AndroidRuntime(22292): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 00:48:04.532: E/AndroidRuntime(22292): at java.lang.reflect.Method.invoke(Method.java:511)
12-02 00:48:04.532: E/AndroidRuntime(22292): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
12-02 00:48:04.532: E/AndroidRuntime(22292): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
12-02 00:48:04.532: E/AndroidRuntime(22292): at dalvik.system.NativeStart.main(Native Method)
12-02 00:48:04.532: E/AndroidRuntime(22292): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.content.res.Resources.getValue(Resources.java:1041)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2191)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.content.res.Resources.getLayout(Resources.java:880)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-02 00:48:04.532: E/AndroidRuntime(22292): at pitermemo.android.gui.dialogs.PMDialogFragment.onCreateView(PMDialogFragment.java:50)
12-02 00:48:04.532: E/AndroidRuntime(22292): at pitermemo.android.gui.dialogs.DialogHelp.onCreateView(DialogHelp.java:50)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1086)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1877)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:552)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1133)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.Activity.performStart(Activity.java:4475)
12-02 00:48:04.532: E/AndroidRuntime(22292): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1937)
12-02 00:48:04.532: E/AndroidRuntime(22292): ... 11 more
I really don't know what causes that and how to solve this. If it was repeated always, it would be much easier.
I'm thinking perhaps it's somehow related with WebView component which likes to make problems. Another suspicious thing is in onResume of main app I run sometimes AsyncTask. But the log doesn't suggest this.
Do you have any suggestions what can cause this? Thanks in advance. (android min sdk 11, run on device with android 4.0.4).
BroadcastReceiver's code is a separate unit SMSReceiver.java. The Receiver declared in the Manifest with an SMS Receive Intent Filter. So it is "always on". When the application is running or just in the list of last 8 application it's working fine when get incoming SMS. But later, when application is deleted from memory, and only receiver stands by, incoming SMS due to error. The fact that I use in receiver's code Sharedpreferences. When I get some information from received SMS I should save it in preferences for loading by main Activity later.
LogCat shows me a string with error.
public class SmsReceiver extends BroadcastReceiver
{
public static SharedPreferences mStatePrefs;
#Override
public void onReceive(Context context, Intent intent)
{
//... some code
SharedPreferences.Editor ed = mStatePrefs.edit(); //HERE I GET AN EXCEPTION
//... some code
}
}
LogCat log..
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): FATAL EXCEPTION: main
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): java.lang.RuntimeException: Unable to start receiver com.example.android.MyApplication.SmsReceiver: java.lang.NullPointerException
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2034)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at android.app.ActivityThread.access$2400(ActivityThread.java:132)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1098)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at android.os.Handler.dispatchMessage(Handler.java:99)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at android.os.Looper.loop(Looper.java:143)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at android.app.ActivityThread.main(ActivityThread.java:4268)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at java.lang.reflect.Method.invokeNative(Native Method)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at java.lang.reflect.Method.invoke(Method.java:507)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at dalvik.system.NativeStart.main(Native Method)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): Caused by: java.lang.NullPointerException
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at com.example.android.MyApplication.SmsReceiver.onReceive(SmsReceiver.java:198)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2019)
12-02 22:36:03.887: ERROR/AndroidRuntime(18345): ... 10 more
So it works fine when app is active or in memory. But when the receiver was left alone, the error has occurred. So what I need to do, to fix this problem? It's a block bug for my app, this receiver is main solution, a sense of program. It must work always and save information in preferences.
You never get a SharedPreference instance for mStatePrefs. Looking at just the code you show, mStatePrefs would still be null.
Try:
mStatePrefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor ed = mStatePrefs.edit();