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
5
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…
5
votes
2 answers

Crashlytics with StrictMode enabled (detect all) gives "untagged socket detected"

I've tried adding Crashlytics to my app, which already has StrictMode enabled with detectAll(). The result was Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage. Full Stack: E/StrictMode:…
MikeL
  • 2,756
  • 2
  • 23
  • 41
5
votes
1 answer

Detecting forgotten SQLite transaction on Android using StrictMode?

Executing multiple SQL statements without putting them into one transaction is a severe bottleneck (see e.g. http://www.sqlite.org/faq.html#q19). I haven't thoroughly checked how SQLite is configured on Android, but anecdotally I perceived…
jonasb
  • 1,847
  • 1
  • 17
  • 15
5
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
  • 4,043
  • 4
  • 24
  • 36
5
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
  • 37,759
  • 6
  • 111
  • 158
5
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
  • 2,338
  • 5
  • 35
  • 55
5
votes
1 answer

Strict mode violations list

running adb logcat in the shell i see something like this StrictMode policy violation; ~duration=337 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2 what the policy=23 means ? what is violation=2 ? I was searching for…
Lukap
  • 31,523
  • 64
  • 157
  • 244
4
votes
1 answer

StrictMode prior 2.3

I was googleing the enableing StrictMode prior 2.3 but I couldn't find anything useful. All I found was that StrictMode is introduced in 2.3 and you can use reflection to check if there is strict mode like this try { Class sMode =…
Lukap
  • 31,523
  • 64
  • 157
  • 244
4
votes
0 answers

addPreferencesFromResource() causing StrictMode violation on Android

I have few fragments extending PreferenceFragmentCompat class from "preference-v8-28.0.0". In order to inflate the view i use addPreferencesFromResource(..) as follows: @Override public void onCreatePreferences(Bundle bundle, String key) { …
4ntoine
  • 19,816
  • 21
  • 96
  • 220
4
votes
2 answers

When start strict mode and set `android:persistent` to `true` will has error. How can I fix this error?

When start strict mode and set android:persistent to true will has error. How can I fix this error? Thanks. Application override fun onCreate() { if (BuildConfig.DEBUG) { setStrictMode() } super.onCreate() } private fun…
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,163
  • 2
  • 22
  • 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
  • 469
  • 2
  • 11
  • 22
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
  • 3
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…
1 2
3
8 9