在android lollipop上显示Toast时出现ArrayIndexOutOfBoundsException

时间:2015-08-01 00:35:39

标签: android android-5.0-lollipop toast

java.lang.ArrayIndexOutOfBoundsException: length=7; index=7
at android.content.res.Resources.toPreloadCookie(Resources.java:2447)
at android.content.res.Resources.loadDrawable(Resources.java:2475)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.view.View.<init>(View.java:3806)
at android.view.ViewGroup.<init>(ViewGroup.java:492)
at android.widget.LinearLayout.<init>(LinearLayout.java:200)
at android.widget.LinearLayout.<init>(LinearLayout.java:196)
at android.widget.LinearLayout.<init>(LinearLayout.java:192)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Toast.makeText(Toast.java:254)
at com.A.B.C.onPostExecute(SourceFile:1)
at android.os.AsyncTask.finish(AsyncTask.java:632)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:645)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.app.ActivityThread.main(ActivityThread.java:5321)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1016)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:811)

我收到了一些像这样的bug报告,只有Sony Lollipop(5.0.2,API21)用户才知道。没有任何其他棒棒糖用户的报告。我想知道可能是什么问题,索尼有没有错误的实施或者棒棒糖需要什么新东西?

编辑:添加了代码

Toast.makeText(getApplicationContext(),"toast text",Toast.LENGTH_SHORT).show();

1 个答案:

答案 0 :(得分:0)

您不应该使用Application上下文来创建Toast,与Service / ContentProvider / BroadcastReceiver上下文相同。您可以在本文中阅读上下文功能部分:Context, What Context?

希望它有所帮助。