Questions tagged [android-strictmode]

This mode helps a developer to identify potential bugs in an app.

From Android Developer Docs:

StrictMode is a developer tool which detects things you might be doing by accident and brings them to your attention so you can fix them.

StrictMode is most commonly used to catch accidental disk or network access on the application's main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application's main thread responsive, you also prevent ANR dialogs from being shown to users.

128 questions
119
votes
6 answers

Should accessing SharedPreferences be done off the UI Thread?

With the release of Gingerbread, I have been experimenting with some of the new API's, one of them being StrictMode. I noticed that one of the warnings is for getSharedPreferences(). This is the warning: StrictMode policy violation; ~duration=1949…
cottonBallPaws
  • 20,217
  • 37
  • 119
  • 169
50
votes
6 answers

Android StrictMode InstanceCountViolation

I am running my app with StrictMode activated in development as documented here StrictMode for lower platform versions and noticed an error message that I do not know what to think about nor can I find any reference. I get a…
Manfred Moser
  • 28,342
  • 13
  • 87
  • 120
32
votes
6 answers

A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks

i am getting this message in logcat A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. where to look for leak and what does it meant by " See java.io.Closeable"
dreamer1989
  • 954
  • 3
  • 10
  • 29
31
votes
1 answer

Android P (API 28) - What does the StrictMode policy violation "SmartSelectionEventTracker$SelectionEvent;->selectionAction" mean?

I am using the StrictMode in order to find non-SDK usages: if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() .detectNonSdkApiUsage() …
hamena314
  • 2,589
  • 4
  • 26
  • 54
16
votes
2 answers

Android Honeycomb: NetworkOnMainThreadException even when using AsyncTask and no strict mode?

I run into a NetworkOnMainThreadException with my Android 3.0 app. Searching for a solution I found this, but if I understand this correctly, default setting would be that the strict mode is turned off. Also, all my network access is in an…
16
votes
1 answer

DropBoxManager use cases?

I noticed that a DropBoxManager has been introduced in Android API since FroYo (API 8). It looks like an alternative logger capable of logging not only text but also files or byte arrays, but I could not find any detailed doc anywhere about how and…
Kevin Gaudin
  • 9,647
  • 3
  • 29
  • 34
15
votes
3 answers

StrictMode java.lang.Throwable: Untagged socket detected

With StrictMode enabled I just started getting this exception: java.lang.Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage
Jose Gómez
  • 2,891
  • 2
  • 28
  • 52
13
votes
3 answers

Finding what violated StrictMode policy

I've enabled StrictMode in my app and it's causing a few crashes as expected. How can I find out where in my code I'm violating these policies? This is the stack trace: E/AndroidRuntime(19523): FATAL EXCEPTION: main E/AndroidRuntime(19523):…
copolii
  • 13,331
  • 9
  • 46
  • 76
12
votes
6 answers

StrictMode for lower platform versions

I have started using the Android StrictMode and find that it would be great to have it always running during development and not just on a special branch I created in git. The reason I did this is my apps requirement to run with 1.6 and up. I read…
Manfred Moser
  • 28,342
  • 13
  • 87
  • 120
12
votes
6 answers

Gingerbread emulator instance is much more sluggish than Froyo and below. Why?

I'm not sure if anyone else noticed it, but the Gingerbread emulator runs like a dog, with both scrolling, navigating, interaction - all taking much longer and being much choppier. I even got an ANR in the browser when I tried to use it:…
11
votes
4 answers

Definition of DEVELOPER_MODE for StrictMode

I'm anxiously awaiting the open source release of StrictMode for continuation of our platform development. The sample in the Android blog entry suggests surrounding the StrictMode calls with if (DEVELOPER_MODE) { ... } For SDK development, I'd…
Dave Boldt
  • 111
  • 1
  • 3
10
votes
1 answer

StrictMode: How to disable "Untagged socket detected" in Android for targetSdk >= 28

I'm trying to disable one of Android StrictMode checks - detection of untagged sockets. I have several reasons to do this: Some libraries used in our app e.g. Crashlytics / Picasso e.t.c. are using OkHttp internally and StrictMode detects untagged…
9
votes
1 answer

Android StrictMode reporting false positives

I have been trying to run my application in StrictMode to check for any hidden problem that may have sneaked. One issue I ran across is what seems to be a false positive of Leaked DatabaseConections when using ContentResolver. After some experiments…
StefanK
  • 2,010
  • 2
  • 14
  • 14
8
votes
4 answers

StrictMode complains about InputStream not being closed

I'm getting the following violation reported by StrictMode in Android. 02-05 04:07:41.190: ERROR/StrictMode(15093): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource…
8
votes
2 answers

Opening a sub-activity several times causes an InstanceCountViolation despite being destroyed

I'm working on a project that has a lower level activity called RecordView to display record details such as an image, the date and time it was taken, and the latitude/longitude information. Rather than trying to manipulate the camera to geotag and…
thegrinner
  • 9,633
  • 5
  • 39
  • 64
1
2 3
8 9