在TextView

时间:2015-10-05 22:38:00

标签: android android-strictmode

使用参数android:autoLink =“phone”创建包含带有电话号码的TextView的布局时,存在StrictModeDiskRead违规。

这是使用com.android.support:appcompat-v7:22.2.0

删除autoLink参数会导致违规。

有没有办法解决这个问题?

堆栈跟踪:

  

D / StrictMode:StrictMode策略违规; 〜持续时间= 108毫秒:   android.os.StrictMode $ StrictModeDiskReadViolation:policy = 31   违反= 2               在android.os.StrictMode $ AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:1135)               在libcore.io.BlockGuardOs.open(BlockGuardOs.java:106)               在libcore.io.IoBridge.open(IoBridge.java:393)               在java.io.RandomAccessFile。(RandomAccessFile.java:118)               在java.io.RandomAccessFile。(RandomAccessFile.java:150)               在java.util.zip.ZipFile。(ZipFile.java:149)               在java.util.jar.JarFile。(JarFile.java:187)               在libcore.net.url.JarURLConnectionImpl.openJarFile(JarURLConnectionImpl.java:136)               在libcore.net.url.JarURLConnectionImpl.findJarFile(JarURLConnectionImpl.java:113)               在libcore.net.url.JarURLConnectionImpl.connect(JarURLConnectionImpl.java:82)               在libcore.net.url.JarURLConnectionImpl.getInputStream(JarURLConnectionImpl.java:215)               在java.net.URL.openStream(URL.java:470)               at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:432)               at java.lang.Class.getResourceAsStream(Class.java:1037)               在com.android.i18n.phonenumbers.PhoneNumberUtil.loadMetadataFromFile(PhoneNumberUtil.java:585)               在com.android.i18n.phonenumbers.PhoneNumberUtil.getMetadataForRegion(PhoneNumberUtil.java:1925)               在com.android.i18n.phonenumbers.PhoneNumberUtil.parseHelper(PhoneNumberUtil.java:2766)               在com.android.i18n.phonenumbers.PhoneNumberUtil.parseAndKeepRawInput(PhoneNumberUtil.java:2679)               在com.android.i18n.phonenumbers.PhoneNumberUtil.parseAndKeepRawInput(PhoneNumberUtil.java:2668)               在com.android.i18n.phonenumbers.PhoneNumberMatcher.parseAndVerify(PhoneNumberMatcher.java:418)               在com.android.i18n.phonenumbers.PhoneNumberMatcher.extractMatch(PhoneNumberMatcher.java:310)               在com.android.i18n.phonenumbers.PhoneNumberMatcher.find(PhoneNumberMatcher.java:240)               在com.android.i18n.phonenumbers.PhoneNumberMatcher.hasNext(PhoneNumberMatcher.java:652)               在android.text.util.Linkify.gatherTelLinks(Linkify.java:454)               在android.text.util.Linkify.addLinks(Linkify.java:230)               在android.widget.TextView.setText(TextView.java:3749)               在android.widget.TextView.setText(TextView.java:3671)               在android.widget.TextView。(TextView.java:1270)               在android.support.v7.widget.AppCompatTextView。(AppCompatTextView.java:44)               在android.support.v7.widget.AppCompatTextView。(AppCompatTextView.java:40)               在android.support.v7.internal.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)               在android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:802)               在android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:832)               在android.support.v4.view.LayoutInflaterCompatHC $ FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)               在android.view.LayoutInflater $ FactoryMerger.onCreateView(LayoutInflater.java:172)               在android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)               在android.view.LayoutInflater.rInflate(LayoutInflater.java:755)               在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)               在android.view.LayoutInflater.parseInclude(LayoutInflater.java:839)               在android.view.LayoutInflater.rInflate(LayoutInflater.java:745)               在android.view.LayoutInflater.rInflate(LayoutInflater.java:758)               在android.view.LayoutInflater.inflate(LayoutInflater.java:492)               在android.view.LayoutInflater.inflate(LayoutInflater.java:397)

编辑:我现在正在使用ViewStub来按需加载此视图,因此它不会减慢应用程序的正常加载速度

1 个答案:

答案 0 :(得分:1)

堆栈跟踪看起来确实很正常。至少,它不是你的代码,它是系统。

来自the docs

  

但是不要觉得有必要修复StrictMode找到的所有东西。特别是,在正常的活动生命周期中,通常需要许多磁盘访问的情况。使用StrictMode查找偶然发生的事情。