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
4
votes
2 answers

What is the lifecycle for Android's StrictMode?

I'm trying to minimize the number of places in my code where I need to setup StrictMode. But I'm not sure if I'm right or not about the following. The documentation for Android's StrictMode says you can use it for Applications, Activities and other…
Dave MacLean
  • 5,094
  • 1
  • 20
  • 30
4
votes
1 answer

StrictMode AndroidBlockGuardPolicy.onReadFromDisk

I faced with the next problem: StrictMode policy violation; ~duration=2235 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=65567 violation=2 at…
Ruslan Leshchenko
  • 2,865
  • 2
  • 16
  • 31
4
votes
1 answer

StrictMode policy violation: StrictModeDiskReadViolation,WriteViolation in Android

I am working an Android project that uses Google maps. The app is working perfectly in my Cell phone, having 5.1.1 Android version, because I used it for the development of the project, but the same app is not working in other cell phone (6.0.0…
user6750923
  • 409
  • 1
  • 8
  • 20
4
votes
1 answer

Cant see StrictMode details on logcat - Suppressed StrictMode policy violation on screen rotation

My problem is this, I'm trying to understand the source of this trace: 11-06 22:07:36.593 2744-3492/com.spot.spottester W/f: Suppressed StrictMode policy violation: StrictModeDiskReadViolation 11-06 22:07:36.594 2744-2744/com.spot.spottester W/f:…
4
votes
2 answers

How can I use StrictMode.noteSlowCall?

I just want to use StrictMode.noteSlowCall . I don't know what to do. Developer site/androidxref don't have enough explanation. Below is my code. @Override public void onCreate() { StrictMode.ThreadPolicy.Builder builder = new…
jhee
  • 41
  • 2
4
votes
0 answers

GreenDao violating Android StrictMode

When using GreenDao and enabling StrictMode i get the following DiskReadViolation: 11-10 12:17:55.777 28694-28694/? D/StrictMode: StrictMode policy violation; ~duration=80 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=589855…
4
votes
0 answers

Where is this ParcelFileDescriptor Leak Occurring?

I have implemented a BackupAgent following the guidelines for Data Backup. The code behaves as expected until StrictMode.VmPolicy is set to detect leaked closeable objects. After a backup is performed and GC occurs, CloseGuard reports a leaked…
Bob Snyder
  • 34,825
  • 4
  • 101
  • 144
4
votes
0 answers

StrictMode ViewActivity; instances=2; limit=1

I have a Gridview with images in Fragment on my FragmentActivity. Gridview onItemClick I call Activity Intent intent = new Intent(getSherlockActivity(), ViewActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); …
Sever
  • 1,531
  • 3
  • 26
  • 48
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,221
  • 10
  • 39
  • 63
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
  • 13,417
  • 7
  • 75
  • 117
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
  • 1,959
  • 4
  • 23
  • 54
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
  • 437
  • 1
  • 6
  • 15
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,496
  • 11
  • 65
  • 84
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
  • 9,447
  • 11
  • 41
  • 56
3
votes
1 answer

Android's StrictMode penaltyListener gives NoClassDefFoundError

I'm adding StrictMode to my app and it works great until I add a custom ViolationListener. It seems it cannot find the callback I'm providing and detects that as an error, too. Could you give me a hand with that? The following code works just…
1 2
3
8 9