| public static XmlPullParser getParser(String xml) { | |
| try { | |
| byte[] data = Base64.decode(xml, Base64.DEFAULT); | |
| // XmlBlock block = new XmlBlock(LAYOUT.getBytes("UTF-8")); | |
| Class<?> clazz = Class.forName("android.content.res.XmlBlock"); | |
| Constructor<?> constructor = clazz.getDeclaredConstructor(byte[].class); | |
| constructor.setAccessible(true); | |
| Object block = constructor.newInstance(data); | |
| // XmlPullParser parser = block.newParser(); | |
| Method method = clazz.getDeclaredMethod("newParser"); | |
| method.setAccessible(true); | |
| return (XmlPullParser) method.invoke(block); | |
| } catch (ClassNotFoundException e) { | |
| e.printStackTrace(); | |
| } catch (NoSuchMethodException e) { | |
| e.printStackTrace(); | |
| } catch (IllegalArgumentException e) { | |
| e.printStackTrace(); | |
| } catch (java.lang.InstantiationException e) { | |
| e.printStackTrace(); | |
| } catch (IllegalAccessException e) { | |
| e.printStackTrace(); | |
| } catch (InvocationTargetException e) { | |
| e.printStackTrace(); | |
| } | |
| return null; | |
| } |