对于java.lang.IllegalStateException:只有全屏不透明活动才能请求方向感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于ajax–java.lang.Illega
对于java.lang.IllegalStateException:只有全屏不透明活动才能请求方向感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于ajax – java.lang.IllegalStateException:CDATA标签可能不嵌套、Android java.lang.IllegalStateException:无法执行活动的方法、android – IllegalStateException:只有全屏不透明活动才能请求方向、android – java.lang.IllegalStateException:没有活动的宝贵知识。
本文目录一览:- java.lang.IllegalStateException:只有全屏不透明活动才能请求方向
- ajax – java.lang.IllegalStateException:CDATA标签可能不嵌套
- Android java.lang.IllegalStateException:无法执行活动的方法
- android – IllegalStateException:只有全屏不透明活动才能请求方向
- android – java.lang.IllegalStateException:没有活动
java.lang.IllegalStateException:只有全屏不透明活动才能请求方向
我在从 Android 8.0 Oreo java.lang.IllegalStateException
中的通讯录中检索联系人时遇到问题:只有全屏不透明活动可以请求方向
我正在尝试从电话通讯录中获取活动中的联系人,它非常适合棒棒糖、棉花糖、牛轧糖等,但它会给我这样的奥利奥错误,请帮助我。我的代码在下面。
演示代码:-
private void loadContacts() { contactAsync = new ContactLoaderAsync(); contactAsync.execute(); } private class ContactLoaderAsync extends AsyncTask<Void, Void, Void> { private Cursor numCursor; @Override protected void onPreExecute() { super.onPreExecute(); Uri numContacts = ContactsContract.CommonDataKinds.Phone.CONTENT_URI; String[] numProjection = new String[]{ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone.TYPE}; if (android.os.Build.VERSION.SDK_INT < 11) { numCursor = InviteByContactActivity.this.managedQuery(numContacts, numProjection, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " COLLATE NOCASE ASC"); } else { CursorLoader cursorLoader = new CursorLoader(InviteByContactActivity.this, numContacts, numProjection, null, null, ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + " COLLATE NOCASE ASC"); numCursor = cursorLoader.loadInBackground(); } } @Override protected Void doInBackground(Void... params) { if (numCursor.moveToFirst()) { try { final int contactIdIndex = numCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID); final int displayNameIndex = numCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME); final int numberIndex = numCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER); final int typeIndex = numCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE); String displayName, number, type; do { displayName = numCursor.getString(displayNameIndex); number = numCursor.getString(numberIndex); type = getContactTypeString(numCursor.getString(typeIndex), true); final ContactModel contact = new ContactModel(displayName, type, number); phoneNumber = number.replaceAll(" ", "").replaceAll("\\(", "").replaceAll("\\)", "").replaceAll("-", ""); if (phoneNumber != null || displayName != null) { contacts.add(phoneNumber); contactsName.add(displayName); contactsChecked.add(false); filterdNames.add(phoneNumber); filterdContactNames.add(displayName); filterdCheckedNames.add(false); } } while (numCursor.moveToNext()); } finally { numCursor.close(); } } Collections.sort(contacts, new Comparator<String>() { @Override public int compare(String lhs, String rhs) { return lhs.compareToIgnoreCase(rhs); } }); InviteByContactActivity.this.runOnUiThread(new Runnable() { @Override public void run() { mContactAdapter.notifyDataSetChanged(); } }); return null; } } private String getContactTypeString(String typeNum, boolean isPhone) { String type = PHONE_TYPES.get(typeNum); if (type == null) return "other"; return type; } static HashMap<String, String> PHONE_TYPES = new HashMap<String, String>(); static { PHONE_TYPES.put(ContactsContract.CommonDataKinds.Phone.TYPE_HOME + "", "home"); PHONE_TYPES.put(ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE + "", "mobile"); PHONE_TYPES.put(ContactsContract.CommonDataKinds.Phone.TYPE_WORK + "", "work"); }}
错误日志:-
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example, PID: 6573 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.Activity.InviteByContactActivity}: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation Caused by: java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
答案1
小编典典当您的目标 sdk 为 28 时,问题似乎正在发生。因此,在尝试了许多选项之后,这终于奏效了。
<activity android:name=".activities.FilterActivity" android:theme="@style/Transparent" android:windowSoftInputMode="stateHidden|adjustResize" />
风格:-
<style name="Transparent" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:windowIsFloating">true</item> <item name="android:windowContentOverlay">@null</item> <item name="android:windowNoTitle">true</item> <item name="android:backgroundDimEnabled">false</item> </style>
注意:api 28 需要 parent=”Theme.AppCompat.Light.NoActionBar”。以前在 api 26
有其他东西。工作得很好,但在 28 岁时开始出现问题。希望它可以帮助这里的人。编辑:对于某些仅通过设置<itemname="android:windowIsTranslucent">false</item> and <itemname="android:windowIsFloating">false</item>
工作。可能取决于您实施解决方案的方式。在我的情况下,它通过将它们设置为 true 来工作。
ajax – java.lang.IllegalStateException:CDATA标签可能不嵌套
SEVERE: Servlet.service() for servlet Faces Servlet threw exception java.lang.IllegalStateException: CDATA tags may not nest at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startCDATA(HtmlResponseWriter.java:630) at javax.faces.context.ResponseWriterWrapper.startCDATA(ResponseWriterWrapper.java:172) at javax.faces.context.PartialResponseWriter.startError(PartialResponseWriter.java:342) at org.primefaces.context.PrimePartialResponseWriter.startError(PrimePartialResponseWriter.java:210) at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:200) at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:123) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
我认为这是String对象的一些问题,因为当我硬编码站点上显示的JPA实体属性时,一切都OK。然而,当从数据库(Postgresql)中检索实体时,它会引发上述异常。
JSF代码:
<p:column> <f:facet name="header"> Akcja </f:facet> <h:commandButton actionListener="#{mBDocumentMigration.actionEdit(object)}" value="Edytuj" rendered="#{mBDocumentMigration.editingObject == null}" > <f:ajax render="@form" execute="@form" /> </h:commandButton> <h:commandButton action="#{mBDocumentMigration.actionZapisz}" value="Zapisz" rendered="#{mBDocumentMigration.editingObject != null}" > <f:ajax render="@form" execute="@this" /> </h:commandButton> </p:column>
仔细看堆栈跟踪。从底部开始跟踪调用堆栈:
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
因此,它在渲染响应阶段发生。好的,看下一行(上面一行):
at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:123)
嘿,它已经通过Mojarra的内置的ajax异常处理程序AjaxExceptionHandlerImpl!仅在ajax请求期间发生异常时才调用此方法。好的,从下到上阅读下一行:
at com.sun.faces.renderkit.html_basic.HtmlResponseWriter.startCDATA(HtmlResponseWriter.java:630) at javax.faces.context.ResponseWriterWrapper.startCDATA(ResponseWriterWrapper.java:172) at javax.faces.context.PartialResponseWriter.startError(PartialResponseWriter.java:342) at org.primefaces.context.PrimePartialResponseWriter.startError(PrimePartialResponseWriter.java:210) at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:200)
因此,尝试将错误信息写入ajax响应。此信息必须在CDATA块中。然而,启动CDATA块失败如下,因为显然已经有一个CDATA块打开了:
java.lang.IllegalStateException: CDATA tags may not nest
这又表示在编写ajax响应时发生异常,很可能是因为您在生成HTML输出时仅调用getter方法执行业务逻辑。所以这个过程最有可能如下:
> JSF进入RENDER_RESPONSE阶段。
> JSF需要生成HTML输出。
>对于每个< f:ajax render =“some”> (或< p:ajax update =“some”>)),则需要创建< update id =“some”>在CDATA block之间生成的HTML输出的XML块(以保持XML输出在语法上有效)。所以需要启动一个CDATA块。
>将HTML输出生成到CDATA块中时,会对所有渲染时EL表达式进行求值,包括所有UI组件的value属性。
>在某个地方,EL表达式后面的getter会抛出一个由你自己的代码中的错误引起的异常。
> JSF会立即停止生成HTML输出,并没有关闭CDATA块。 HTTP响应包含半记录数据。
> AjaxExceptionHandlerImpl被触发。
> AjaxExceptionHandlerImpl需要将异常/错误详细信息写入响应。但是,它没有检查响应是否已经被写入。它盲目地尝试打开一个CDATA块,由此它已经被打开了。它抛出了你看到的异常,隐藏了所有关于它试图处理的真正的底层异常的细节。
你可以看到,问题是双重的:
> JSF渲染器不应该让响应halfbaked。
> Mojarra的AjaxExceptionHandlerImpl应该已经检查/验证了响应的状态。
如果您用custom one which immediately prints the stack trace或OmniFaces FullAjaxExceptionHandler
which is capable of detecting and cleaning halfbaked ajax responses替换Mojarra的内置ajax异常处理程序,那么最终会显示和显示代码中的错误引起的真正原因。如前所述,这很可能是performing business logic in a getter method,which is a bad practice造成的。
Android java.lang.IllegalStateException:无法执行活动的方法
您好,我是学习android的新手,我正尝试在学习Android时制作一个半有用的应用程序(对我自己),基本上我是在第一时间接受有用的Java代码(ping
X,端口扫描)并添加将它们添加到我的应用中,我无法弄清楚 为什么
会发生此错误,我确实认为这与代码的第77行有关,但是我想了解为什么它无法正常工作,因此下次我可以更好地帮助自己。很抱歉出现罗word的问题,我不知道什么时候闭嘴。
01-25 20:42:42.139: E/AndroidRuntime(1307): FATAL EXCEPTION: main
01-25 20:42:42.139: E/AndroidRuntime(1307): java.lang.IllegalStateException: Could not execute method of the activity
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.view.View$1.onClick(View.java:3597)
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.view.View.performClick(View.java:4202)
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.view.View$PerformClick.run(View.java:17340)
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.os.Handler.handleCallback(Handler.java:725)
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.os.Looper.loop(Looper.java:137)
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-25 20:42:42.139: E/AndroidRuntime(1307): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:42:42.139: E/AndroidRuntime(1307): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:42:42.139: E/AndroidRuntime(1307): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-25 20:42:42.139: E/AndroidRuntime(1307): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-25 20:42:42.139: E/AndroidRuntime(1307): at dalvik.system.NativeStart.main(Native Method)
01-25 20:42:42.139: E/AndroidRuntime(1307): Caused by: java.lang.reflect.InvocationTargetException
01-25 20:42:42.139: E/AndroidRuntime(1307): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:42:42.139: E/AndroidRuntime(1307): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:42:42.139: E/AndroidRuntime(1307): at android.view.View$1.onClick(View.java:3592)
01-25 20:42:42.139: E/AndroidRuntime(1307): ... 11 more
01-25 20:42:42.139: E/AndroidRuntime(1307): Caused by: java.lang.NullPointerException
01-25 20:42:42.139: E/AndroidRuntime(1307): at com.seven.up.MainActivity.OnClickPort(MainActivity.java:77)
01-25 20:42:42.139: E/AndroidRuntime(1307): ... 14 more
01-25 20:44:42.549: E/MPL-storeload(511): calData from inv_save_mpl_states,size=2
01-25 20:45:39.759: E/InputDispatcher(511): channel '41b55368 com.seven.up/com.seven.up.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
01-25 20:45:50.279: E/AndroidRuntime(1625): FATAL EXCEPTION: main
01-25 20:45:50.279: E/AndroidRuntime(1625): java.lang.IllegalStateException: Could not execute method of the activity
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.view.View$1.onClick(View.java:3597)
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.view.View.performClick(View.java:4202)
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.view.View$PerformClick.run(View.java:17340)
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.os.Handler.handleCallback(Handler.java:725)
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.os.Looper.loop(Looper.java:137)
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-25 20:45:50.279: E/AndroidRuntime(1625): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:45:50.279: E/AndroidRuntime(1625): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:45:50.279: E/AndroidRuntime(1625): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-25 20:45:50.279: E/AndroidRuntime(1625): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-25 20:45:50.279: E/AndroidRuntime(1625): at dalvik.system.NativeStart.main(Native Method)
01-25 20:45:50.279: E/AndroidRuntime(1625): Caused by: java.lang.reflect.InvocationTargetException
01-25 20:45:50.279: E/AndroidRuntime(1625): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:45:50.279: E/AndroidRuntime(1625): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:45:50.279: E/AndroidRuntime(1625): at android.view.View$1.onClick(View.java:3592)
01-25 20:45:50.279: E/AndroidRuntime(1625): ... 11 more
01-25 20:45:50.279: E/AndroidRuntime(1625): Caused by: java.lang.NullPointerException
01-25 20:45:50.279: E/AndroidRuntime(1625): at com.seven.up.MainActivity.OnClickPort(MainActivity.java:78)
01-25 20:45:50.279: E/AndroidRuntime(1625): ... 14 more
01-25 20:46:32.409: E/InputDispatcher(511): channel '416e8e78 com.seven.up/com.seven.up.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
01-25 20:46:35.449: E/AndroidRuntime(1830): FATAL EXCEPTION: main
01-25 20:46:35.449: E/AndroidRuntime(1830): java.lang.IllegalStateException: Could not execute method of the activity
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.view.View$1.onClick(View.java:3597)
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.view.View.performClick(View.java:4202)
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.view.View$PerformClick.run(View.java:17340)
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.os.Handler.handleCallback(Handler.java:725)
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.os.Looper.loop(Looper.java:137)
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-25 20:46:35.449: E/AndroidRuntime(1830): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:46:35.449: E/AndroidRuntime(1830): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:46:35.449: E/AndroidRuntime(1830): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-25 20:46:35.449: E/AndroidRuntime(1830): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-25 20:46:35.449: E/AndroidRuntime(1830): at dalvik.system.NativeStart.main(Native Method)
01-25 20:46:35.449: E/AndroidRuntime(1830): Caused by: java.lang.reflect.InvocationTargetException
01-25 20:46:35.449: E/AndroidRuntime(1830): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:46:35.449: E/AndroidRuntime(1830): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:46:35.449: E/AndroidRuntime(1830): at android.view.View$1.onClick(View.java:3592)
01-25 20:46:35.449: E/AndroidRuntime(1830): ... 11 more
01-25 20:46:35.449: E/AndroidRuntime(1830): Caused by: java.lang.NullPointerException
01-25 20:46:35.449: E/AndroidRuntime(1830): at com.seven.up.MainActivity.OnClickPort(MainActivity.java:77)
01-25 20:46:35.449: E/AndroidRuntime(1830): ... 14 more
01-25 20:47:40.119: E/AndroidRuntime(2009): FATAL EXCEPTION: main
01-25 20:47:40.119: E/AndroidRuntime(2009): java.lang.IllegalStateException: Could not execute method of the activity
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.view.View$1.onClick(View.java:3597)
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.view.View.performClick(View.java:4202)
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.view.View$PerformClick.run(View.java:17340)
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.os.Handler.handleCallback(Handler.java:725)
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.os.Looper.loop(Looper.java:137)
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-25 20:47:40.119: E/AndroidRuntime(2009): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:47:40.119: E/AndroidRuntime(2009): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:47:40.119: E/AndroidRuntime(2009): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-25 20:47:40.119: E/AndroidRuntime(2009): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-25 20:47:40.119: E/AndroidRuntime(2009): at dalvik.system.NativeStart.main(Native Method)
01-25 20:47:40.119: E/AndroidRuntime(2009): Caused by: java.lang.reflect.InvocationTargetException
01-25 20:47:40.119: E/AndroidRuntime(2009): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:47:40.119: E/AndroidRuntime(2009): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:47:40.119: E/AndroidRuntime(2009): at android.view.View$1.onClick(View.java:3592)
01-25 20:47:40.119: E/AndroidRuntime(2009): ... 11 more
01-25 20:47:40.119: E/AndroidRuntime(2009): Caused by: java.lang.NullPointerException
01-25 20:47:40.119: E/AndroidRuntime(2009): at com.seven.up.MainActivity.OnClickPort(MainActivity.java:77)
01-25 20:47:40.119: E/AndroidRuntime(2009): ... 14 more
01-25 20:49:29.979: E/InputDispatcher(511): channel '414e7770 com.seven.up/com.seven.up.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
01-25 20:49:30.149: E/jdwp(2216): Failed sending reply to debugger: Broken pipe
01-25 20:49:41.599: E/MPL-storeload(511): calData from inv_save_mpl_states,size=2
01-25 20:50:12.539: E/InputDispatcher(511): channel '41c0a160 com.seven.up/com.seven.up.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
01-25 20:50:13.629: E/InputManager-JNI(511): An exception was thrown by callback 'interceptKeyBeforeQueueing'.
01-25 20:50:13.629: E/InputManager-JNI(511): java.lang.NullPointerException
01-25 20:50:13.629: E/InputManager-JNI(511): at com.android.internal.policy.impl.PhoneWindowManager.interceptKeyBeforeQueueing(PhoneWindowManager.java:3948)
01-25 20:50:13.629: E/InputManager-JNI(511): at com.android.server.wm.InputMonitor.interceptKeyBeforeQueueing(InputMonitor.java:337)
01-25 20:50:13.629: E/InputManager-JNI(511): at com.android.server.input.InputManagerService.interceptKeyBeforeQueueing(InputManagerService.java:1346)
01-25 20:50:13.629: E/InputManager-JNI(511): at dalvik.system.NativeStart.run(Native Method)
01-25 20:50:13.899: E/InputManager-JNI(511): An exception was thrown by callback 'interceptKeyBeforeQueueing'.
01-25 20:50:13.899: E/InputManager-JNI(511): java.lang.NullPointerException
01-25 20:50:13.899: E/InputManager-JNI(511): at com.android.internal.policy.impl.PhoneWindowManager.interceptKeyBeforeQueueing(PhoneWindowManager.java:3948)
01-25 20:50:13.899: E/InputManager-JNI(511): at com.android.server.wm.InputMonitor.interceptKeyBeforeQueueing(InputMonitor.java:337)
01-25 20:50:13.899: E/InputManager-JNI(511): at com.android.server.input.InputManagerService.interceptKeyBeforeQueueing(InputManagerService.java:1346)
01-25 20:50:13.899: E/InputManager-JNI(511): at dalvik.system.NativeStart.run(Native Method)
01-25 20:50:19.759: E/InputDispatcher(511): channel '41419b38 com.seven.up/com.seven.up.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
01-25 20:51:49.459: E/WeatherXmlParser(2522): Couldn't parse Yahoo weather XML
01-25 20:51:49.459: E/WeatherXmlParser(2522): java.lang.NumberFormatException: Invalid float: ""
01-25 20:51:49.459: E/WeatherXmlParser(2522): at java.lang.StringToReal.invalidReal(StringToReal.java:63)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at java.lang.StringToReal.parseFloat(StringToReal.java:289)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at java.lang.Float.parseFloat(Float.java:300)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at com.cyanogenmod.lockclock.weather.WeatherXmlParser.getFloatForAttribute(WeatherXmlParser.java:86)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at com.cyanogenmod.lockclock.weather.WeatherXmlParser.parseWeatherResponse(WeatherXmlParser.java:108)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at com.cyanogenmod.lockclock.weather.WeatherUpdateService$WeatherUpdateTask.doInBackground(WeatherUpdateService.java:210)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at com.cyanogenmod.lockclock.weather.WeatherUpdateService$WeatherUpdateTask.doInBackground(WeatherUpdateService.java:126)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at android.os.AsyncTask$2.call(AsyncTask.java:287)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
01-25 20:51:49.459: E/WeatherXmlParser(2522): at java.lang.Thread.run(Thread.java:856)
01-25 20:52:24.619: E/MPL-storeload(511): calData from inv_save_mpl_states,size=2
01-25 20:57:07.229: E/AndroidRuntime(2410): FATAL EXCEPTION: main
01-25 20:57:07.229: E/AndroidRuntime(2410): java.lang.IllegalStateException: Could not execute method of the activity
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.view.View$1.onClick(View.java:3597)
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.view.View.performClick(View.java:4202)
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.view.View$PerformClick.run(View.java:17340)
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.os.Handler.handleCallback(Handler.java:725)
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.os.Looper.loop(Looper.java:137)
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-25 20:57:07.229: E/AndroidRuntime(2410): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:57:07.229: E/AndroidRuntime(2410): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:57:07.229: E/AndroidRuntime(2410): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-25 20:57:07.229: E/AndroidRuntime(2410): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-25 20:57:07.229: E/AndroidRuntime(2410): at dalvik.system.NativeStart.main(Native Method)
01-25 20:57:07.229: E/AndroidRuntime(2410): Caused by: java.lang.reflect.InvocationTargetException
01-25 20:57:07.229: E/AndroidRuntime(2410): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:57:07.229: E/AndroidRuntime(2410): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:57:07.229: E/AndroidRuntime(2410): at android.view.View$1.onClick(View.java:3592)
01-25 20:57:07.229: E/AndroidRuntime(2410): ... 11 more
01-25 20:57:07.229: E/AndroidRuntime(2410): Caused by: java.lang.NullPointerException
01-25 20:57:07.229: E/AndroidRuntime(2410): at com.seven.up.MainActivity.OnClickPort(MainActivity.java:77)
01-25 20:57:07.229: E/AndroidRuntime(2410): ... 14 more
01-25 20:59:12.549: E/AndroidRuntime(3168): FATAL EXCEPTION: main
01-25 20:59:12.549: E/AndroidRuntime(3168): java.lang.IllegalStateException: Could not execute method of the activity
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.view.View$1.onClick(View.java:3597)
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.view.View.performClick(View.java:4202)
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.view.View$PerformClick.run(View.java:17340)
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.os.Handler.handleCallback(Handler.java:725)
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.os.Handler.dispatchMessage(Handler.java:92)
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.os.Looper.loop(Looper.java:137)
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.app.ActivityThread.main(ActivityThread.java:5191)
01-25 20:59:12.549: E/AndroidRuntime(3168): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:59:12.549: E/AndroidRuntime(3168): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:59:12.549: E/AndroidRuntime(3168): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
01-25 20:59:12.549: E/AndroidRuntime(3168): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
01-25 20:59:12.549: E/AndroidRuntime(3168): at dalvik.system.NativeStart.main(Native Method)
01-25 20:59:12.549: E/AndroidRuntime(3168): Caused by: java.lang.reflect.InvocationTargetException
01-25 20:59:12.549: E/AndroidRuntime(3168): at java.lang.reflect.Method.invokeNative(Native Method)
01-25 20:59:12.549: E/AndroidRuntime(3168): at java.lang.reflect.Method.invoke(Method.java:511)
01-25 20:59:12.549: E/AndroidRuntime(3168): at android.view.View$1.onClick(View.java:3592)
01-25 20:59:12.549: E/AndroidRuntime(3168): ... 11 more
01-25 20:59:12.549: E/AndroidRuntime(3168): Caused by: java.lang.NullPointerException
01-25 20:59:12.549: E/AndroidRuntime(3168): at com.seven.up.MainActivity.OnClickPort(MainActivity.java:76)
01-25 20:59:12.549: E/AndroidRuntime(3168): ... 14 more
01-25 21:01:13.939: E/MPL-storeload(511): calData from inv_save_mpl_states,size=2
package com.seven.up;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.*;
import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity implements OnClickListener {
EditText ip_address_field;
TextView scan_out;
TextView port_results;
EditText startPort;
EditText stopPort;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ip_address_field = (EditText) findViewById(R.id.ip_address_field);
ip_address_field.getText();
scan_out = (TextView) findViewById(R.id.scan_out);
Button scan_button = (Button) findViewById(R.id.scan_button);
scan_button.setOnClickListener(this);
}
public void onClick(View v) {
Editable host = ip_address_field.getText();
switch (v.getId()) {
case R.id.scan_button:
try {
String pingCmd = "ping -c 5 " + host;
String pingResult = "";
Runtime r = Runtime.getRuntime();
Process p = r.exec(pingCmd);
BufferedReader in = new BufferedReader(new InputStreamReader(
p.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println(inputLine);
scan_out.setText(inputLine + "\n" + "\n");
pingResult += inputLine;
scan_out.setText("/n" + pingResult);
}
in.close();
}// try
catch (IOException e) {
System.out.println(e);
}
break;
default:
break;
}
}
public void OnClickPort(View v) {
switch (v.getId()) {
case R.id.button1:
int startPortRange = Integer.parseInt(startPort.getText().toString());
int stopPortRange = Integer.parseInt(stopPort.getText().toString());
for (int i = startPortRange; i <= stopPortRange; i++) {
try {
Socket ServerSok = new Socket("192.168.0.1",i);
Toast.makeText(getApplicationContext(),"Port in use: " + i,Toast.LENGTH_LONG).show();
ServerSok.close();
} catch (Exception e) {
}
System.out.println("Port not in use: " + i);
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_main,menu);
return super.onCreateOptionsMenu(menu);
}
}
android – IllegalStateException:只有全屏不透明活动才能请求方向
当设备处于横向状态时,请将我误解为错误
java.lang.IllegalStateException: Only fullscreen opaque activities can request orientation
表现
<activity android:name=".Activity.MyActivity" android:configChanges="orientation" android:screenorientation="portrait" android:theme="@style/AppTheme.Theme_Slide" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.broWSABLE" /> <data android:host="xxx" android:scheme="xxx" /> <data android:host="xxx" android:scheme="xxx" /> </intent-filter> </activity>
style.xml
<style name="AppTheme.Theme_Slide" parent="Theme.AppCompat.Light.NoActionBar"> <item name="android:windowIsTranslucent">true</item> <item name="android:windowCloSEOnTouchOutside">false</item> </style>
解决方法
寻找解决方案
在android Oreo中,你不能改变Activity的方向
<item name="android:windowIsTranslucent">true</item>
在风格.您必须先从清单中删除以下行
android:screenorientation="portrait"
其次,您必须将此行添加到java文件中
//android O fix bug orientation if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }
android – java.lang.IllegalStateException:没有活动
我正在构建一个Android应用程序,我希望我的第一个活动由2个选项卡组成,一个用于用户的配置文件,另一个用于朋友的活动.对于这些标签,我选择了TabHost,因为我的Sherlock Action Bar已经使用列表导航移动到其他活动,因此我无法使用操作栏中的标签导航.
该应用程序工作了一段时间,但现在只有我的一个选项卡工作,一旦我尝试移动到第二个选项卡,我得到一个java.lang.IllegalStateException:没有活动
我为这个错误添加了Logcat输出,虽然我不确定它是否有帮助,因为我的代码没有回溯.
我尝试用FragmentTabHost替换TabHost,但错误仍然存在……
任何人都可以向我指出这个错误的起源/含义吗?提前致谢 !
LOGCAT:
04-03 08:19:39.380: W/dalvikvm(958): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-03 08:19:39.400: E/AndroidRuntime(958): FATAL EXCEPTION: main
04-03 08:19:39.400: E/AndroidRuntime(958): java.lang.IllegalStateException: No activity
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:1075)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:1070)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:1861)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:1474)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:931)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.movetoState(FragmentManager.java:1088)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.os.Handler.handleCallback(Handler.java:725)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.os.Handler.dispatchMessage(Handler.java:92)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.os.Looper.loop(Looper.java:137)
04-03 08:19:39.400: E/AndroidRuntime(958): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-03 08:19:39.400: E/AndroidRuntime(958): at java.lang.reflect.Method.invokeNative(Native Method)
04-03 08:19:39.400: E/AndroidRuntime(958): at java.lang.reflect.Method.invoke(Method.java:511)
04-03 08:19:39.400: E/AndroidRuntime(958): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-03 08:19:39.400: E/AndroidRuntime(958): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-03 08:19:39.400: E/AndroidRuntime(958): at dalvik.system.NativeStart.main(Native Method)
活动
public class HomeActivity extends SherlockFragmentActivity implements ActionBar.OnNavigationListener {
private ActionBar mActionBar;
private TabHost tHost;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_activity_layout);
//Setting the list navigation on actionBar
mActionBar = getSupportActionBar();
Context context = getSupportActionBar().getThemedContext();
ArrayAdapter<CharSequence> list = ArrayAdapter.createFromresource(context, R.array.list_menu_items, R.layout.sherlock_spinner_item);
list.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
mActionBar.setdisplayShowTitleEnabled(false);
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
mActionBar.setListNavigationCallbacks(list, this);
//Setting the subnavigation with TabHost
tHost = (TabHost) findViewById(android.R.id.tabhost);
tHost.setup();
/** Defining tab builder for profile tab */
TabHost.TabSpec tabSpecProfile = tHost.newTabSpec("profile");
tabSpecProfile.setIndicator("PROFILE");
tabSpecProfile.setContent(new TabContentMaker(this));
tHost.addTab(tabSpecProfile);
/** Defining tab builder for community tab */
TabHost.TabSpec tabSpecCommunity = tHost.newTabSpec("community");
tabSpecCommunity.setIndicator("COMmunitY");
tabSpecCommunity.setContent(new TabContentMaker(this));
tHost.addTab(tabSpecCommunity);
/** Defining Tab Change Listener event. This is invoked when tab is changed */
TabHost.OnTabchangelistener tabchangelistener = getonTabchangelistener();
/** Setting tabchangelistener for the tab */
tHost.setonTabChangedListener(tabchangelistener);
}
@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
//changing activity here
return true;
}
private TabHost.OnTabchangelistener getonTabchangelistener(){
TabHost.OnTabchangelistener tabchangelistener = new TabHost.OnTabchangelistener() {
@Override
public void onTabChanged(String tabId) {
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
MyProfileFragment profileFragment = (MyProfileFragment) fm.findFragmentByTag("profile");
CommunityFeedFragment communityFragment = (CommunityFeedFragment) fm.findFragmentByTag("community");
android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();
/** Detaches the profileFragment if exists */
if(profileFragment!=null)
ft.detach(profileFragment);
/** Detaches the communityFragment if exists */
if(communityFragment!=null)
ft.detach(communityFragment);
/** If current tab is profile */
if(tabId.equalsIgnoreCase("profile")){
if(profileFragment==null){
/** Create MyProfileFragment and adding to fragmenttransaction */
ft.add(R.id.realtabcontent,new MyProfileFragment(), "profile");
}else{
/** Bring to the front, if already exists in the fragmenttransaction */
ft.attach(profileFragment);
}
}else{ /** If current tab is community */
if(communityFragment==null){
/** Create CommunityFragment and adding to fragmenttransaction */
ft.add(R.id.realtabcontent,new CommunityFeedFragment(), "community");
}else{
/** Bring to the front, if already exists in the fragmenttransaction */
ft.attach(communityFragment);
}
}
ft.commit();
}
};
return tabchangelistener;
}
ANDROID MANIFEST
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.enlavertical"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.Styled" >
<activity
android:name="com.enlavertical.HomeActivity"
android:label="@string/app_name"
android:screenorientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
解决方法:
最后发现了这是什么:“无活动”崩溃是由于我使用错误的FragmentManager来嵌套Fragments.
对于嵌套片段,唯一有效的FragmentManager是通过调用getChildFragmentManager()
在包含Fragment中获得的片段.
关于java.lang.IllegalStateException:只有全屏不透明活动才能请求方向的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于ajax – java.lang.IllegalStateException:CDATA标签可能不嵌套、Android java.lang.IllegalStateException:无法执行活动的方法、android – IllegalStateException:只有全屏不透明活动才能请求方向、android – java.lang.IllegalStateException:没有活动等相关内容,可以在本站寻找。
本文标签: