Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the exceptions that are easy to be ignored in android

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is to share with you about the exceptions in android that are easy to ignore. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

1. You need to open a new task when opening activity externally. This exception occurs when you open activity from service.

W/System.err: android.util.AndroidRuntimeException: Calling startActivity () from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?W/System.err: at android.app.ContextImpl.startActivity (ContextImpl.java:944) W/System.err: at android.app.ContextImpl.startActivity (ContextImpl.java:931)

Indicates that you want to add a Flag. The recommended FLAG_ACTIVITY_NEW_TASK is an activity startup method to create a new activity.

two。 Adding addHeaderView () after setAdapter () will cause an exception.

When first introduced, this method could only be called before setting the adapter with setAdapter (ListAdapter). Starting with KITKAT, this method may be called at any time.

KITKAT:October 2013: Android 4.4, KitKat, another tasty treat. Android can be called anywhere after 4.4, and versions prior to 4.4 will report an error.

W/System.err: java.lang.IllegalStateException: Cannot add header view to list-- setAdapter has already been called.W/System.err: at android.widget.ListView.addHeaderView (ListView.java:257) W/System.err: at android.widget.ListView.addHeaderView (ListView.java:286)

3.TextView.setText () can only put parameters of the charsequence class. If you put an integer number, it will report the following error.

The string resource id can also be placed in the setText () of the reason for this exception. If you put an integer, the string corresponding to the id will be found in the R file, so there will be an exception of NotFoundException, that is, the text corresponding to the resource id cannot be found.

Note: the subclass of the CharSequence class is String,StringBuffer,StringBuilder

E/InputEventReceiver: Exception dispatching input event.E/MessageQueue-JNI: Exception in MessageQueue callback: handleReceiveCallbackE/MessageQueue-JNI: android.content.res.Resources$NotFoundException: String resource ID # 0x28

Monitoring problems with 4.spinner settings

If you use onItemClickListener, an exception will occur, as follows.

SetOnItemClickListener cannot be used with a spinner.

You should use onItemSelectedListener, which is an easy pit to step on.

W/System.err: java.lang.RuntimeException: Unable to start activity java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.W/System.err: at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2180) W/System.err: at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2230) W/System.err: at android.app.ActivityThread.access$600 (ActivityThread.java:141) W/System.err: at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1234) W / System.err: at android.os.Handler.dispatchMessage (Handler.java:99) W/System.err: at android.os.Looper.loop (Looper.java:137) W/System.err: at android.app.ActivityThread.main (ActivityThread.java:5041) W/System.err: at java.lang.reflect.Method.invokeNative (Native Method) W/System.err: at java.lang.reflect.Method.invoke (Method.java:511) W/System.err: at com.android .room.os.ZygoteInit $MethodAndArgsCaller.run (ZygoteInit.java:793) W/System.err: at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:560) W/System.err: at dalvik.system.NativeStart.main (Native Method) W/System.err: Caused by: java.lang.RuntimeException: setOnItemClickListener cannot be used with a spinner.

5. An exception occurs when the progressDialog.show () method is called in service

If the progress is not set to hover over other applications and the corresponding permissions are set, then when dialog.show () is called in other components such as service, the current windows will not be obtained, so the dialog cannot be displayed normally.

W/System.err: android.view.WindowManager$BadTokenException: Unable to add window-- token null is not for an applicationW/System.err: at android.view.ViewRootImpl.setView (ViewRootImpl.java:571) W/System.err: at android.view.WindowManagerGlobal.addView (WindowManagerGlobal.java:246) W/System.err: at android.view.WindowManagerImpl.addView (WindowManagerImpl.java:69) W/System.err: at android.app.Dialog.show (Dialog.java:281) / / context is application progressDialog = new ProgressDialog (context) ProgressDialog.setMessage (msg); progressDialog.setCancelable (cancelable); progressDialog.setCanceledOnTouchOutside (false); progressDialog.show (); Thank you for reading! This is the end of this article on "what are the anomalies that are easy to be ignored in android". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report