android-strictmode

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

三世轮回 提交于 2020-01-01 09:13:11
问题 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 access exif data I'm trying to implement a location listener to get the location where the image is first taken (on the button press). This approach works - I get my location to display and update the record in the database correctly (returning to

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

試著忘記壹切 提交于 2019-12-31 03:58:05
问题 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: null java.lang.Throwable: Untagged socket detected; use TrafficStats.setThreadSocketTag() to track all network usage at android.os.StrictMode.onUntaggedSocket(StrictMode.java:2012) at com.android.server.NetworkManagementSocketTagger.tag(NetworkManagementSocketTagger

Filter Android StrictMode violations by duration

时间秒杀一切 提交于 2019-12-31 02:03:50
问题 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 think StrictMode is a useful feature, but I'd like to deal only with violations with a duration greater than, let's say, 50 ms, in the first development phase. 回答1: The StrictMode API does not support filtering by duration. But you can easily do so

How to run this code in a Thread or Async Task?

自作多情 提交于 2019-12-25 06:41:19
问题 When I tried running this code I get an error, about the strictMode Thread policy, so I added this line. StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); I later discovered this is not the best approach that I have to run it in a Thread or an ansync task, so i will like to run it in a thread or an Asynctask. Please help edit my code when answering @Override protected void onCreate(Bundle savedInstanceState) { super

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

本秂侑毒 提交于 2019-12-22 08:55:46
问题 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. These lists are showing data items that are generated asynchronously in another thread; as it needs to know where to send updates to, the data objects it manipulates have WeakReference<> objects that are set to hold references to the adapters

Android StrictMode InstanceCountViolation

孤人 提交于 2019-12-18 10:22:53
问题 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 android.os.StrictMode$InstanceCountViolation with values for instances and limit e.g. instances=3; limit=2 Now I am wondering: A) how is the limit calculated B) how can such a violation actually happen and then I would look into evasive actions. Any ideas? 回答1: It's all

Android StrictMode and heap dumps

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 05:01:12
问题 When Android's StrictMode detects a leaked object (e.g. activity) violation, it would be helpful if I could capture a heap dump at that moment in time. There's no obvious way, however, to configure it to do this. Does anyone know of some trick that can be used to achieve it, e.g. a way to convince the system to run a particular piece of code just prior to the death penalty being invoked? I don't think StrictMode throws an exception, so I can't use the trick described here: Is there a way to

Android StrictMode policy

梦想的初衷 提交于 2019-12-14 03:47:13
问题 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 a difference in the top 4 line and the duration? And why are there 2 violations anyway - does this mean that the code was executed twice? Any help appreciated 08-15 14:24:14.314: DEBUG/StrictMode(767): StrictMode policy violation; ~duration=13876

Using StrictMode in app production phase

回眸只為那壹抹淺笑 提交于 2019-12-11 20:33:02
问题 I know that StrictMode designed mainly to be used in application development phase, but according to my app needs, it's not acceptable to get ANR while it's quite acceptable to get crash, and StrictMode provides a way to prevent ANR dialogs: StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll() .penaltyLog().penaltyDeath().build()); what if I used it inside the app production phase? and what will happen when the app getting ANR while StrictMode used? will it freeze, crash, or

Instance count violation in an Android Java app

落爺英雄遲暮 提交于 2019-12-11 06:48:51
问题 I am working on an Android application. In abstract, this application has an UI in order to interact with user and it also interacts with a remote service. The remote service adds a notification to Android launcher bar and this notification allows to redisplay the UI. The app and the service are in same package. The code of service notification function: private void showNotification (String contentText) { Intent intent = new Intent (this, my_app.class); intent.addFlags(Intent.FLAG_ACTIVITY