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.

135 questions
4
votes
1 answer

Filter Android StrictMode violations by duration

Is there a way to filter StrictMode violations based on duration? It's getting a bit annoying having these StrictMode policy violation; ~duration=6 ms: android.os.StrictMode$StrictModeDiskWriteViolation: policy=31 violation=1 poisoning my logcat. I…
Ivan Morgillo
  • 2,837
  • 4
  • 30
  • 46
4
votes
0 answers

StrictMode$InstanceCountViolation when changing orientation

I have an activity with tabs and I have problem when I rotate the device. When I start e.g. the app in portrait mode then rotate to the landscape and again to the portrait then the app is crashed and in LogCat I…
Bartosz Bialecki
  • 4,391
  • 10
  • 42
  • 64
4
votes
1 answer

Android strict mode detects multiple activity instance violation, but I have no idea why

Code is probably too complex to post here in full, but here is the basic schema: I have two Activity subclasses, each of which hosts a ListView. Each ListView has an adapter of a custom class, which generates View instances also of a custom class. …
Jules
  • 14,841
  • 9
  • 83
  • 130
4
votes
2 answers

Strict Mode complains on resource leak

Strict mode complains the following: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.: **response = httpclient.execute(httpPost);** Below is my code: …
muneikh
  • 2,067
  • 5
  • 25
  • 59
4
votes
1 answer

Android StrictMode policy

Running into some ANR issues with an android application so I implemented the StrictMode policies. Never used this before so hopefully someone can help explain the following: Why does the log show 2 violations which are seemingly similar apart from…
Kern
  • 447
  • 1
  • 6
  • 16
4
votes
2 answers

StrictModeBuilder permitAll not working

I do have an old app that refuses to work on Android 4.1 devices. It's the NetworkOnMainThreadException that jumps in here. So I tried to permit this with the following steps - but these don't work. I tested that with the 4.1 emulator. What is…
Harald Wilhelm
  • 6,656
  • 11
  • 67
  • 85
3
votes
6 answers

Strict mode in android 2.2

I have target sdk set as 3.2 and min sdk as 2.2, how can I use strictmode in my application, as I understand it is introduced but cannot really understand how to start using it.
Vaibhav Mishra
  • 11,384
  • 12
  • 45
  • 58
3
votes
2 answers

Powershell object cannot be found with strictmode latest

I am trying to get below to work under set-strictmode -version latest, it works completely fine without strict mode, unfortunately it's a requirement to have latest strictmode in my environment. What it does: go through registry to find the entry…
Jeff
  • 33
  • 2
3
votes
1 answer

Simple Android project crashing by StrictMode ThreadPolicy violation, strictmode.DiskReadViolation

I have created new Android project, an empty activity project and used StrictMode but the application crashes every time due to strictmode.DiskReadViolation I fallow the answer of my similar question asked here StrictMode disk read violation on…
Arvindo
  • 117
  • 1
  • 9
3
votes
1 answer

kotlin coroutines disk violation strict mode

I have lifecycle aware coroutine abstract class AppViewModel : ViewModel(), CoroutineScope { private val job = Job() override val coroutineContext: CoroutineContext get() = Dispatchers.Main + job override fun onCleared() { …
3
votes
1 answer

StrictMode confusion - how is this the wrong thread?

My issue: 12-18 17:05:03.336: DEBUG/StrictMode(2112): StrictMode policy violation; ~duration=2073 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2 From the factory method 12-18 17:05:03.336: DEBUG/StrictMode(2112): …
smith324
  • 13,020
  • 9
  • 37
  • 58
3
votes
0 answers

Picasso: A resource was acquired at attached stack trace but never released

While loading image using Picasso I'm setting an error reported by StrictMode. This happens when I go to a DetailActivity view. 07-24 15:57:32.346 12190-12199/com.example.flicks E/StrictMode: A resource was acquired at attached stack trace but…
Monu Surana
  • 694
  • 1
  • 6
  • 20
3
votes
1 answer

Why StrictMode does not catch read/write operations by SQLite?

In my app I have the following setup for StrictMode: StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() .detectDiskReads() .detectDiskWrites() .detectNetwork() .penaltyLog() …
Ognyan
  • 13,452
  • 5
  • 64
  • 82
3
votes
3 answers

Android Strict Mode

I have written a simple code on JSON Parsing using AsyncTask. I'm just displaying the response in TextView. I don't know whether it is right or wrong. Its working on GingerBread and showing NetworkOnMainThreadException on JellyBean. If I use…
DroidLearner
  • 2,115
  • 5
  • 31
  • 50
3
votes
1 answer

Maven and Android Backward Compatibility (android.os.StrictMode)

I am new to maven and is trying to setup an android project with it. I am done with the basic setup using maven-android-plugin, and is able to build my project successfully. I have added min-sdk version to my project pom as…
1 2 3
8 9