问:
Integrate Mopub in cocos2d-x v.3.x
I am facing a problem integrating Mopub Banner & Intersitial inside an Android App.
I tried to add it in multiple manners but no one is working.

Someone has managed to integrate it?
I manage to cache the ads, but when they get shown , nothing appears...the app seems to get blocked and get black screen, after few seconds it get automatically closed whitou writing any clear error log ..

Have you faced something similar?
I Want to avoid SDKBOX since it does not support Mopub.
Thanks

This is a capture of the Log:

```8:30:17.406 2115-2115/? D/STATUSBAR-NetworkController: refreshSignalCluster:

data=-1 bt=false
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge W/dalvikvm: threadid=1: spin on suspend #3 threadid=16 (pcf=0)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=0 dsCount=0 obj=0x40fe1508 self=0x40fd1660
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13827 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1075257136
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 485168449 392425546 912 ) utm=33 stm=15 core=0
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:~82)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.StringBuffer.<init>(StringBuffer.java:69)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.util.regex.Matcher.replaceAll(Matcher.java:320)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.String.replaceAll(String.java:1784)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:77)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:93)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidController.<init>(MraidController.java:122)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.getAdView(MraidActivity.java:109)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.BaseInterstitialActivity.onCreate(BaseInterstitialActivity.java:58)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.onCreate(MraidActivity.java:168)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Activity.performCreate(Activity.java:5047)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.access$700(ActivityThread.java:134)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Looper.loop(Looper.java:137)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.main(ActivityThread.java:4867)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invokeNative(Native Method)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invoke(Method.java:511)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at dalvik.system.NativeStart.main(Native Method)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "GLThread 805" prio=5 tid=16 RUNNABLE
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=1 dsCount=0 obj=0x41a7ed20 self=0x5a35b590
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13876 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1513470432
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 1092346170 769592302 3068 ) utm=93 stm=16 core=1
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.nativeOnPause(Native Method)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.handleOnPause(Cocos2dxRenderer.java:158)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxGLSurfaceView$4.run(Cocos2dxGLSurfaceView.java:197)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
06-07 18:30:18.036 1691-1998/? I/sec_anm_ahi_output: standby() called
06-07 18:30:18.036 1691-1998/? I/sec_anm_ahi_output: Trying to drain devices
06-07 18:30:18.036 1694-1961/? I/ADM: 9: 31950741777: [INFO] api_devset:824 devapi_drain, draining 41398008.0
06-07 18:30:18.056 1694-1961/? I/ADM: 8: 31950767076: [INFO] omx_io:651 il_tool_io_empty_buffer_done: Idle callback requested, issuing..
06-07 18:30:18.056 1694-1961/? I/ADM: 0: 31950767137: [INFO] api_devset:835 Drain complete, sending reply msg
06-07 18:30:18.056 1691-1998/? I/sec_anm_ahi_output: Drain devices done
06-07 18:30:18.056 1691-1998/? I/sec_anm_ahi_output: adm_api: ste_adm_close_device(Speaker)
06-07 18:30:18.056 1694-1961/? I/ADM: 3: 31950767381: [STATUS] api_devset:316 Close device 'Speaker'
06-07 18:30:18.056 1694-1961/? I/ADM: 6: 31950767533: [OMXIL] omx_log:957 41398008 [ADM.splitter]: SendCommand PortDisable 0
06-07 18:30:18.056 1694-1961/? I/ADM: 7: 31950767564: [INFO] omx_io:410 il_tool_io_wait_until_idle: 42DD5008.0 idle, returning
06-07 18:30:18.056 1694-1961/? I/ADM: 8: 31950767625: [OMXIL] omx_log:1113 41398008 [ADM.splitter]: FreeBuf port=0 pBuf=456F6F88
06-07 18:30:18.056 1694-1961/? I/ADM: 9: 31950767656: [OMXIL] omx_log:1113 41398008 [ADM.splitter]: FreeBuf port=0 pBuf=4003BF38
06-07 18:30:18.056 1694-1961/? I/ADM: 9: 31950767686: [OMXIL] omx_log:1113 41398008 [ADM.splitter]: FreeBuf port=0 pBuf=41377F18
06-07 18:30:18.056 1694-1961/? I/ADM: 0: 31950767747: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete PortDisable 0
06-07 18:30:18.056 1694-1961/? I/ADM: 2: 31950767869: [OMXIL] omx_log:957 41398008 [ADM.splitter]: SendCommand PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 3: 31950767930: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 4: 31950767961: [OMXIL] omx_log:957 45DDB008 [ADM.mixer   ]: SendCommand PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 4: 31950768022: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: CB CmdComplete PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 6: 31950768113: [INFO] dev:519  >>> ENTER dev_close(101)
06-07 18:30:18.056 1694-1961/? I/ADM: 8: 31950768235: [INFO] dev:306 setting /data/local/tmp/rme_act_adm to 1
06-07 18:30:18.056 1694-1961/? I/ADM: 1: 31950768418: [INFO] dev:347 rme alp tracker /data/local/tmp/rme_act_alp set to 0: proceeding
06-07 18:30:18.056 1694-1961/? I/ADM: 4: 31950769212: [INFO] dev_omx:1517 Enter dev_omx_close_graph - logical_handle=1  dealloc_buffers=0
06-07 18:30:18.056 1694-1961/? I/ADM: 5: 31950769273: [INFO] dev_omx:1534 Closing last device. Request audiocodec to ramp down audio
06-07 18:30:18.056 1694-1961/? I/ADM: 6: 31950769303: [OMXIL] omx_log:913 41378CC0 [X.ST.AFM.IHF]: SetConfig idx=Mute
06-07 18:30:18.056 1694-1961/? I/ADM: 7: 31950769334: [OMXIL] omx_log:293     port=0 mute=1
06-07 18:30:18.096 1694-1968/? I/ADM: 8: 31950802415: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB EventIndexSettingChanged port=67108901 index=OMX_ALL
06-07 18:30:18.096 1694-1968/? I/ADM: 9: 31950802476: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB EventIndexSettingChanged port=-1 index=Mute
06-07 18:30:18.096 1694-1961/? I/ADM: 8: 31950803025: [INFO] dev_omx_graph:1181 Enter graph_disconnect_app_effects_from_common_mix_split
06-07 18:30:18.096 1694-1961/? I/ADM: 0: 31950803697: [OMXIL] omx_log:957 41378570 [ocessing.spl]: SendCommand PortDisable 1
06-07 18:30:18.096 1694-1961/? I/ADM: 8: 31950804185: [OMXIL] omx_log:957 413782E0 [ST.AFM.mixer]: SendCommand PortDisable 1
06-07 18:30:18.096 1694-1968/? I/ADM: 9: 31950805436: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: CB CmdComplete PortDisable 1
06-07 18:30:18.096 1694-1968/? I/ADM: 7: 31950807054: [OMXIL] omx_log:256 41378570 [ocessing.spl]: CB CmdComplete PortDisable 1
06-07 18:30:18.096 1694-1961/? I/ADM: 9: 31950807237: [OMXIL] omx_log:954 45DDB008 [ADM.mixer   ]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 1: 31950807298: [OMXIL] omx_log:954 41378570 [ocessing.spl]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1981/? I/ADM: 6: 31950807634: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.096 1694-1968/? I/ADM: 1: 31950807908: [OMXIL] omx_log:256 41378570 [ocessing.spl]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 5: 31950808152: [OMXIL] omx_log:954 413782E0 [ST.AFM.mixer]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1968/? I/ADM: 4: 31950808702: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 5: 31950808702: [OMXIL] omx_log:954 413788E8 [ocessing.spl]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 1: 31950809129: [OMXIL] omx_log:954 41378CC0 [X.ST.AFM.IHF]: SendCommand StateSet StateIdle
06-07 18:30:18.106 1694-1968/? I/ADM: 2: 31950810289: [OMXIL] omx_log:256 413788E8 [ocessing.spl]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.106 1694-1968/? I/ADM: 2: 31950811540: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.106 1694-1961/? I/ADM: 0: 31950811937: [OMXIL] omx_log:954 41378CC0 [X.ST.AFM.IHF]: SendCommand StateSet StateLoaded
06-07 18:30:18.117 1694-1968/? I/ADM: 0: 31950820848: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.117 1694-1961/? I/ADM: 3: 31950820970: [OMXIL] omx_log:954 413788E8 [ocessing.spl]: SendCommand StateSet StateLoaded
06-07 18:30:18.117 1694-1968/? I/ADM: 9: 31950826677: [OMXIL] omx_log:256 413788E8 [ocessing.spl]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.117 1694-1961/? I/ADM: 1: 31950826799: [OMXIL] omx_log:954 413782E0 [ST.AFM.mixer]: SendCommand StateSet StateLoaded
06-07 18:30:18.127 1694-1968/? I/ADM: 1: 31950831468: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 3: 31950831620: [OMXIL] omx_log:954 41378570 [ocessing.spl]: SendCommand StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 7: 31950838914: [OMXIL] omx_log:954 45DDB008 [ADM.mixer   ]: SendCommand StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 8: 31950839006: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.127 1694-1968/? I/ADM: 5: 31950839433: [OMXIL] omx_log:256 41378570 [ocessing.spl]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 2: 31950839830: [OMXIL] omx_log:256 41378570 [ocessing.spl]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 3: 31950840501: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 7: 31950840684: [OMXIL] omx_log:256 413788E8 [ocessing.spl]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 5: 31950841142: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 3: 31950841600: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 0: 31950842088: [INFO] dev_omx:1646 All OMX handles freed successfully
06-07 18:30:18.137 1694-1961/? I/ADM: 1: 31950842149: [INFO] dev_omx:1722 Graph closed successfully! ref_cnt = 0
06-07 18:30:18.137 1694-1961/? I/ADM: 4: 31950842302: [INFO] dev:1684 rescan_hw_handler
06-07 18:30:18.137 1694-1961/? I/ADM: 5: 31950842393: [INFO] hw_handler_u8500:461 AddD2DConnections ENTER
06-07 18:30:18.137 1694-1961/? I/ADM: 1: 31950843309: [INFO] dev:1675 hw_handler_dev_next_d2d: DONE
06-07 18:30:18.137 1694-1961/? I/ADM: 4: 31950843461: [INFO] dev:1654 hw_handler_dev_next: DONE
06-07 18:30:18.137 1694-1961/? I/ADM: 5: 31950844102: [INFO] hw_handler_u8500:849 Query: SELECT * FROM HW_Settings WHERE (Platform = 'AB8500') AND (Dev1 ='')ORDER BY rowid LIMIT 1
06-07 18:30:18.137 1694-1961/? I/ADM: 6: 31950845933: [INFO] hw_handler_u8500:961 ste_adm_hw_handler_u8500: Found matching HW-settings: devices = ('', '', '', '', '', ''), d2dlogical-connections = ('', '', '', '').
06-07 18:30:18.157 1694-1961/? I/ADM: 4: 31950861192: [INFO] dev:834 Updating event subscriptions for device Speaker
06-07 18:30:18.157 1694-1961/? I/ADM: 6: 31950861253: [INFO] dev:579  >>> LEAVE dev_close(101)
06-07 18:30:18.157 1694-1961/? I/ADM: 8: 31950861375: [INFO] dev:306 setting /data/local/tmp/rme_act_adm to 0
06-07 18:30:18.157 1694-1961/? I/ADM: 4: 31950862321: [INFO] api_devset:392 Releasing splitter; no longer used
06-07 18:30:18.157 1694-1961/? I/ADM: 5: 31950862413: [OMXIL] omx_log:954 41398008 [ADM.splitter]: SendCommand StateSet StateIdle
06-07 18:30:18.157 1694-1961/? I/ADM: 6: 31950862535: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.157 1694-1961/? I/ADM: 9: 31950862596: [OMXIL] omx_log:954 41398008 [ADM.splitter]: SendCommand StateSet StateLoaded
06-07 18:30:18.157 1694-1961/? I/ADM: 9: 31950862687: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.157 1694-1961/? I/ADM: 1: 31950862748: [OMXIL] omx_log:256 41398008 [ADM.splitter]: FreeHandle
06-07 18:30:18.157 1694-1961/? I/ADM: 2: 31950862809: [INFO] api_devset:408 CloseDevice(Speaker) OK
06-07 18:30:18.417 2115-2115/? D/STATUSBAR-NetworkController: refreshSignalCluster: data=-1 bt=false
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge W/dalvikvm: threadid=1: spin on suspend #4 threadid=16 (pcf=0)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=0 dsCount=0 obj=0x40fe1508 self=0x40fd1660
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13827 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1075257136
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 487091056 410797128 945 ) utm=33 stm=15 core=0
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:~82)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.StringBuffer.<init>(StringBuffer.java:69)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.util.regex.Matcher.replaceAll(Matcher.java:320)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.String.replaceAll(String.java:1784)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:77)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:93)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidController.<init>(MraidController.java:122)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.getAdView(MraidActivity.java:109)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.BaseInterstitialActivity.onCreate(BaseInterstitialActivity.java:58)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.onCreate(MraidActivity.java:168)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Activity.performCreate(Activity.java:5047)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.access$700(ActivityThread.java:134)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Looper.loop(Looper.java:137)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.main(ActivityThread.java:4867)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invokeNative(Native Method)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invoke(Method.java:511)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at dalvik.system.NativeStart.main(Native Method)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "GLThread 805" prio=5 tid=16 RUNNABLE
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=1 dsCount=0 obj=0x41a7ed20 self=0x5a35b590
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13876 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1513470432
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 1092346170 769592302 3068 ) utm=93 stm=16 core=1
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.nativeOnPause(Native Method)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.handleOnPause(Cocos2dxRenderer.java:158)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxGLSurfaceView$4.run(Cocos2dxGLSurfaceView.java:197)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
06-07 18:30:18.887 14042-14042/? A/libc: Fatal signal 13 (SIGPIPE) at 0x000036da (code=0), thread 14042 (sh)
```

答:
Inject dependency in Android build.gradle file

```<code>dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   compile project(':libcocos2dx')

   compile 'com.google.android.gms:play-services-ads:10.0.1'

   compile('com.mopub:mopub-sdk:4.14.0@aar') {
      transitive = true
   }
}
</code>```

Set minSdkVersion 16

```<code>defaultConfig {
   applicationId "com.its.adservice"
   minSdkVersion 16
   targetSdkVersion PROP_TARGET_SDK_VERSION
   versionCode 1
   versionName "1.0"
   ...
}
</code>```

Add required permission and Activity in AndroidManifest.xml file

```<code><uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

<meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />
</code>```

AppActivity

```<code>private static final String AD_UNIT_ID="XXXXXXXXXX";
private static final String INTERSTITIAL_AD_UNIT_ID= "XXXXXXXXX";
private MoPubView moPubView;
public static MoPubInterstitial mInterstitial;

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);

   moPubView = new MoPubView(this);
   moPubView.setAdUnitId(AD_UNIT_ID);
   moPubView.setBannerAdListener(new MoPubView.BannerAdListener(){

    @Override
    public void onBannerLoaded(MoPubView banner) {

    }

    @Override
    public void onBannerFailed(MoPubView banner, MoPubErrorCode errorCode) {

    }

    @Override
    public void onBannerClicked(MoPubView banner) {

    }

    @Override
    public void onBannerExpanded(MoPubView banner) {

    }

    @Override
    public void onBannerCollapsed(MoPubView banner) {

    }
  });

   moPubView.loadAd();

   RelativeLayout relativeLayout=new RelativeLayout(this);

   RelativeLayout.LayoutParams bottomParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   bottomParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
   bottomParams.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE);
   relativeLayout.addView(moPubView, bottomParams);

   addContentView(relativeLayout, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
   relativeLayout.bringToFront();

   mInterstitial = new MoPubInterstitial(androidLauncher, INTERSTITIAL_AD_UNIT_ID);
   mInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener(){

    @Override
    public void onInterstitialLoaded(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {

    }

    @Override
    public void onInterstitialShown(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialClicked(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialDismissed(MoPubInterstitial interstitial) {
            mInterstitial.load();
    }
  });

    mInterstitial.load();
}

@Override
public void onDestroy() {
   moPubView.destroy();
   mInterstitial.destroy();
   super.onDestroy();
}

public static void showOrLoadInterstitial() {
     if (mInterstitial.isReady()) {
         mInterstitial.show();
     } else {
         mInterstitial.load();
     }
 }
</code>```

Whenever you want to show interstitial Ad call static method showOrLoadInterstitial through JNI.

Title: Integrate Mopub in cocos2d-x v.3.x

Body:
I am facing a problem integrating Mopub Banner & Intersitial inside an Android App.
I tried to add it in multiple manners but no one is working.

Someone has managed to integrate it?
I manage to cache the ads, but when they get shown , nothing appears...the app seems to get blocked and get black screen, after few seconds it get automatically closed whitou writing any clear error log ..

Have you faced something similar?
I Want to avoid SDKBOX since it does not support Mopub.
Thanks

This is a capture of the Log:

8:30:17.406 2115-2115/? D/STATUSBAR-NetworkController: refreshSignalCluster:

data=-1 bt=false
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge W/dalvikvm: threadid=1: spin on suspend #3 threadid=16 (pcf=0)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=0 dsCount=0 obj=0x40fe1508 self=0x40fd1660
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13827 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1075257136
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 485168449 392425546 912 ) utm=33 stm=15 core=0
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:~82)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.StringBuffer.<init>(StringBuffer.java:69)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.util.regex.Matcher.replaceAll(Matcher.java:320)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.String.replaceAll(String.java:1784)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:77)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:93)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidController.<init>(MraidController.java:122)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.getAdView(MraidActivity.java:109)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.BaseInterstitialActivity.onCreate(BaseInterstitialActivity.java:58)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.onCreate(MraidActivity.java:168)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Activity.performCreate(Activity.java:5047)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.access$700(ActivityThread.java:134)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Looper.loop(Looper.java:137)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.main(ActivityThread.java:4867)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invokeNative(Native Method)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invoke(Method.java:511)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at dalvik.system.NativeStart.main(Native Method)
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "GLThread 805" prio=5 tid=16 RUNNABLE
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=1 dsCount=0 obj=0x41a7ed20 self=0x5a35b590
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13876 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1513470432
06-07 18:30:17.746 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 1092346170 769592302 3068 ) utm=93 stm=16 core=1
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.nativeOnPause(Native Method)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.handleOnPause(Cocos2dxRenderer.java:158)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxGLSurfaceView$4.run(Cocos2dxGLSurfaceView.java:197)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
06-07 18:30:17.756 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
06-07 18:30:18.036 1691-1998/? I/sec_anm_ahi_output: standby() called
06-07 18:30:18.036 1691-1998/? I/sec_anm_ahi_output: Trying to drain devices
06-07 18:30:18.036 1694-1961/? I/ADM: 9: 31950741777: [INFO] api_devset:824 devapi_drain, draining 41398008.0
06-07 18:30:18.056 1694-1961/? I/ADM: 8: 31950767076: [INFO] omx_io:651 il_tool_io_empty_buffer_done: Idle callback requested, issuing..
06-07 18:30:18.056 1694-1961/? I/ADM: 0: 31950767137: [INFO] api_devset:835 Drain complete, sending reply msg
06-07 18:30:18.056 1691-1998/? I/sec_anm_ahi_output: Drain devices done
06-07 18:30:18.056 1691-1998/? I/sec_anm_ahi_output: adm_api: ste_adm_close_device(Speaker)
06-07 18:30:18.056 1694-1961/? I/ADM: 3: 31950767381: [STATUS] api_devset:316 Close device 'Speaker'
06-07 18:30:18.056 1694-1961/? I/ADM: 6: 31950767533: [OMXIL] omx_log:957 41398008 [ADM.splitter]: SendCommand PortDisable 0
06-07 18:30:18.056 1694-1961/? I/ADM: 7: 31950767564: [INFO] omx_io:410 il_tool_io_wait_until_idle: 42DD5008.0 idle, returning
06-07 18:30:18.056 1694-1961/? I/ADM: 8: 31950767625: [OMXIL] omx_log:1113 41398008 [ADM.splitter]: FreeBuf port=0 pBuf=456F6F88
06-07 18:30:18.056 1694-1961/? I/ADM: 9: 31950767656: [OMXIL] omx_log:1113 41398008 [ADM.splitter]: FreeBuf port=0 pBuf=4003BF38
06-07 18:30:18.056 1694-1961/? I/ADM: 9: 31950767686: [OMXIL] omx_log:1113 41398008 [ADM.splitter]: FreeBuf port=0 pBuf=41377F18
06-07 18:30:18.056 1694-1961/? I/ADM: 0: 31950767747: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete PortDisable 0
06-07 18:30:18.056 1694-1961/? I/ADM: 2: 31950767869: [OMXIL] omx_log:957 41398008 [ADM.splitter]: SendCommand PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 3: 31950767930: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 4: 31950767961: [OMXIL] omx_log:957 45DDB008 [ADM.mixer   ]: SendCommand PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 4: 31950768022: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: CB CmdComplete PortDisable 1
06-07 18:30:18.056 1694-1961/? I/ADM: 6: 31950768113: [INFO] dev:519  >>> ENTER dev_close(101)
06-07 18:30:18.056 1694-1961/? I/ADM: 8: 31950768235: [INFO] dev:306 setting /data/local/tmp/rme_act_adm to 1
06-07 18:30:18.056 1694-1961/? I/ADM: 1: 31950768418: [INFO] dev:347 rme alp tracker /data/local/tmp/rme_act_alp set to 0: proceeding
06-07 18:30:18.056 1694-1961/? I/ADM: 4: 31950769212: [INFO] dev_omx:1517 Enter dev_omx_close_graph - logical_handle=1  dealloc_buffers=0
06-07 18:30:18.056 1694-1961/? I/ADM: 5: 31950769273: [INFO] dev_omx:1534 Closing last device. Request audiocodec to ramp down audio
06-07 18:30:18.056 1694-1961/? I/ADM: 6: 31950769303: [OMXIL] omx_log:913 41378CC0 [X.ST.AFM.IHF]: SetConfig idx=Mute
06-07 18:30:18.056 1694-1961/? I/ADM: 7: 31950769334: [OMXIL] omx_log:293     port=0 mute=1
06-07 18:30:18.096 1694-1968/? I/ADM: 8: 31950802415: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB EventIndexSettingChanged port=67108901 index=OMX_ALL
06-07 18:30:18.096 1694-1968/? I/ADM: 9: 31950802476: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB EventIndexSettingChanged port=-1 index=Mute
06-07 18:30:18.096 1694-1961/? I/ADM: 8: 31950803025: [INFO] dev_omx_graph:1181 Enter graph_disconnect_app_effects_from_common_mix_split
06-07 18:30:18.096 1694-1961/? I/ADM: 0: 31950803697: [OMXIL] omx_log:957 41378570 [ocessing.spl]: SendCommand PortDisable 1
06-07 18:30:18.096 1694-1961/? I/ADM: 8: 31950804185: [OMXIL] omx_log:957 413782E0 [ST.AFM.mixer]: SendCommand PortDisable 1
06-07 18:30:18.096 1694-1968/? I/ADM: 9: 31950805436: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: CB CmdComplete PortDisable 1
06-07 18:30:18.096 1694-1968/? I/ADM: 7: 31950807054: [OMXIL] omx_log:256 41378570 [ocessing.spl]: CB CmdComplete PortDisable 1
06-07 18:30:18.096 1694-1961/? I/ADM: 9: 31950807237: [OMXIL] omx_log:954 45DDB008 [ADM.mixer   ]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 1: 31950807298: [OMXIL] omx_log:954 41378570 [ocessing.spl]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1981/? I/ADM: 6: 31950807634: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.096 1694-1968/? I/ADM: 1: 31950807908: [OMXIL] omx_log:256 41378570 [ocessing.spl]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 5: 31950808152: [OMXIL] omx_log:954 413782E0 [ST.AFM.mixer]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1968/? I/ADM: 4: 31950808702: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 5: 31950808702: [OMXIL] omx_log:954 413788E8 [ocessing.spl]: SendCommand StateSet StateIdle
06-07 18:30:18.096 1694-1961/? I/ADM: 1: 31950809129: [OMXIL] omx_log:954 41378CC0 [X.ST.AFM.IHF]: SendCommand StateSet StateIdle
06-07 18:30:18.106 1694-1968/? I/ADM: 2: 31950810289: [OMXIL] omx_log:256 413788E8 [ocessing.spl]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.106 1694-1968/? I/ADM: 2: 31950811540: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.106 1694-1961/? I/ADM: 0: 31950811937: [OMXIL] omx_log:954 41378CC0 [X.ST.AFM.IHF]: SendCommand StateSet StateLoaded
06-07 18:30:18.117 1694-1968/? I/ADM: 0: 31950820848: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.117 1694-1961/? I/ADM: 3: 31950820970: [OMXIL] omx_log:954 413788E8 [ocessing.spl]: SendCommand StateSet StateLoaded
06-07 18:30:18.117 1694-1968/? I/ADM: 9: 31950826677: [OMXIL] omx_log:256 413788E8 [ocessing.spl]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.117 1694-1961/? I/ADM: 1: 31950826799: [OMXIL] omx_log:954 413782E0 [ST.AFM.mixer]: SendCommand StateSet StateLoaded
06-07 18:30:18.127 1694-1968/? I/ADM: 1: 31950831468: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 3: 31950831620: [OMXIL] omx_log:954 41378570 [ocessing.spl]: SendCommand StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 7: 31950838914: [OMXIL] omx_log:954 45DDB008 [ADM.mixer   ]: SendCommand StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 8: 31950839006: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.127 1694-1968/? I/ADM: 5: 31950839433: [OMXIL] omx_log:256 41378570 [ocessing.spl]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.127 1694-1961/? I/ADM: 2: 31950839830: [OMXIL] omx_log:256 41378570 [ocessing.spl]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 3: 31950840501: [OMXIL] omx_log:256 45DDB008 [ADM.mixer   ]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 7: 31950840684: [OMXIL] omx_log:256 413788E8 [ocessing.spl]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 5: 31950841142: [OMXIL] omx_log:256 41378CC0 [X.ST.AFM.IHF]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 3: 31950841600: [OMXIL] omx_log:256 413782E0 [ST.AFM.mixer]: FreeHandle
06-07 18:30:18.137 1694-1961/? I/ADM: 0: 31950842088: [INFO] dev_omx:1646 All OMX handles freed successfully
06-07 18:30:18.137 1694-1961/? I/ADM: 1: 31950842149: [INFO] dev_omx:1722 Graph closed successfully! ref_cnt = 0
06-07 18:30:18.137 1694-1961/? I/ADM: 4: 31950842302: [INFO] dev:1684 rescan_hw_handler
06-07 18:30:18.137 1694-1961/? I/ADM: 5: 31950842393: [INFO] hw_handler_u8500:461 AddD2DConnections ENTER
06-07 18:30:18.137 1694-1961/? I/ADM: 1: 31950843309: [INFO] dev:1675 hw_handler_dev_next_d2d: DONE
06-07 18:30:18.137 1694-1961/? I/ADM: 4: 31950843461: [INFO] dev:1654 hw_handler_dev_next: DONE
06-07 18:30:18.137 1694-1961/? I/ADM: 5: 31950844102: [INFO] hw_handler_u8500:849 Query: SELECT * FROM HW_Settings WHERE (Platform = 'AB8500') AND (Dev1 ='')ORDER BY rowid LIMIT 1
06-07 18:30:18.137 1694-1961/? I/ADM: 6: 31950845933: [INFO] hw_handler_u8500:961 ste_adm_hw_handler_u8500: Found matching HW-settings: devices = ('', '', '', '', '', ''), d2dlogical-connections = ('', '', '', '').
06-07 18:30:18.157 1694-1961/? I/ADM: 4: 31950861192: [INFO] dev:834 Updating event subscriptions for device Speaker
06-07 18:30:18.157 1694-1961/? I/ADM: 6: 31950861253: [INFO] dev:579  >>> LEAVE dev_close(101)
06-07 18:30:18.157 1694-1961/? I/ADM: 8: 31950861375: [INFO] dev:306 setting /data/local/tmp/rme_act_adm to 0
06-07 18:30:18.157 1694-1961/? I/ADM: 4: 31950862321: [INFO] api_devset:392 Releasing splitter; no longer used
06-07 18:30:18.157 1694-1961/? I/ADM: 5: 31950862413: [OMXIL] omx_log:954 41398008 [ADM.splitter]: SendCommand StateSet StateIdle
06-07 18:30:18.157 1694-1961/? I/ADM: 6: 31950862535: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete StateSet StateIdle
06-07 18:30:18.157 1694-1961/? I/ADM: 9: 31950862596: [OMXIL] omx_log:954 41398008 [ADM.splitter]: SendCommand StateSet StateLoaded
06-07 18:30:18.157 1694-1961/? I/ADM: 9: 31950862687: [OMXIL] omx_log:256 41398008 [ADM.splitter]: CB CmdComplete StateSet StateLoaded
06-07 18:30:18.157 1694-1961/? I/ADM: 1: 31950862748: [OMXIL] omx_log:256 41398008 [ADM.splitter]: FreeHandle
06-07 18:30:18.157 1694-1961/? I/ADM: 2: 31950862809: [INFO] api_devset:408 CloseDevice(Speaker) OK
06-07 18:30:18.417 2115-2115/? D/STATUSBAR-NetworkController: refreshSignalCluster: data=-1 bt=false
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge W/dalvikvm: threadid=1: spin on suspend #4 threadid=16 (pcf=0)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "main" prio=5 tid=1 RUNNABLE
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=0 dsCount=0 obj=0x40fe1508 self=0x40fd1660
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13827 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1075257136
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 487091056 410797128 945 ) utm=33 stm=15 core=0
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:~82)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.StringBuffer.<init>(StringBuffer.java:69)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.util.regex.Matcher.replaceAll(Matcher.java:320)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.String.replaceAll(String.java:1784)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:77)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidBridge.<init>(MraidBridge.java:93)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mraid.MraidController.<init>(MraidController.java:122)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.getAdView(MraidActivity.java:109)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.BaseInterstitialActivity.onCreate(BaseInterstitialActivity.java:58)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.mopub.mobileads.MraidActivity.onCreate(MraidActivity.java:168)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Activity.performCreate(Activity.java:5047)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2056)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2117)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.access$700(ActivityThread.java:134)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1218)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.os.Looper.loop(Looper.java:137)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.app.ActivityThread.main(ActivityThread.java:4867)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invokeNative(Native Method)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at java.lang.reflect.Method.invoke(Method.java:511)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at dalvik.system.NativeStart.main(Native Method)
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm: "GLThread 805" prio=5 tid=16 RUNNABLE
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | group="main" sCount=1 dsCount=0 obj=0x41a7ed20 self=0x5a35b590
06-07 18:30:18.507 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | sysTid=13876 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1513470432
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:   | schedstat=( 1092346170 769592302 3068 ) utm=93 stm=16 core=1
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.nativeOnPause(Native Method)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxRenderer.handleOnPause(Cocos2dxRenderer.java:158)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at org.cocos2dx.lib.Cocos2dxGLSurfaceView$4.run(Cocos2dxGLSurfaceView.java:197)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
06-07 18:30:18.517 13827-13827/com.kangaroo.logicchallenge I/dalvikvm:     at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
06-07 18:30:18.887 14042-14042/? A/libc: Fatal signal 13 (SIGPIPE) at 0x000036da (code=0), thread 14042 (sh)

Body:
Inject dependency in Android build.gradle file

dependencies {
   compile fileTree(dir: 'libs', include: ['*.jar'])
   compile project(':libcocos2dx')

   compile 'com.google.android.gms:play-services-ads:10.0.1'

   compile('com.mopub:mopub-sdk:4.14.0@aar') {
      transitive = true
   }
}

Set minSdkVersion 16

defaultConfig {
   applicationId "com.its.adservice"
   minSdkVersion 16
   targetSdkVersion PROP_TARGET_SDK_VERSION
   versionCode 1
   versionName "1.0"
   ...
}

Add required permission and Activity in AndroidManifest.xml file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>
<activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

<meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />

AppActivity

private static final String AD_UNIT_ID="XXXXXXXXXX";
private static final String INTERSTITIAL_AD_UNIT_ID= "XXXXXXXXX";
private MoPubView moPubView;
public static MoPubInterstitial mInterstitial;

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);

   moPubView = new MoPubView(this);
   moPubView.setAdUnitId(AD_UNIT_ID);
   moPubView.setBannerAdListener(new MoPubView.BannerAdListener(){

    @Override
    public void onBannerLoaded(MoPubView banner) {

    }

    @Override
    public void onBannerFailed(MoPubView banner, MoPubErrorCode errorCode) {

    }

    @Override
    public void onBannerClicked(MoPubView banner) {

    }

    @Override
    public void onBannerExpanded(MoPubView banner) {

    }

    @Override
    public void onBannerCollapsed(MoPubView banner) {

    }
  });

   moPubView.loadAd();

   RelativeLayout relativeLayout=new RelativeLayout(this);

   RelativeLayout.LayoutParams bottomParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
   bottomParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM,RelativeLayout.TRUE);
   bottomParams.addRule(RelativeLayout.CENTER_HORIZONTAL,RelativeLayout.TRUE);
   relativeLayout.addView(moPubView, bottomParams);

   addContentView(relativeLayout, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
   relativeLayout.bringToFront();

   mInterstitial = new MoPubInterstitial(androidLauncher, INTERSTITIAL_AD_UNIT_ID);
   mInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener(){

    @Override
    public void onInterstitialLoaded(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {

    }

    @Override
    public void onInterstitialShown(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialClicked(MoPubInterstitial interstitial) {

    }

    @Override
    public void onInterstitialDismissed(MoPubInterstitial interstitial) {
            mInterstitial.load();
    }
  });

    mInterstitial.load();
}

@Override
public void onDestroy() {
   moPubView.destroy();
   mInterstitial.destroy();
   super.onDestroy();
}

public static void showOrLoadInterstitial() {
     if (mInterstitial.isReady()) {
         mInterstitial.show();
     } else {
         mInterstitial.load();
     }
 }

Whenever you want to show interstitial Ad call static method showOrLoadInterstitial through JNI.


来源: stackexchange

问:
Set search hint dynamically
Does anybody knows how to set android search dialog hint dynamically?
T have try to do something like:

```<code><?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
 android:label="@string/search_label"
 android:hint="@string/search_hint"
 android:id="@+id/search_dialog_text">
</searchable>
</code>```

Somewhere:

```<code>@Override
public boolean onSearchRequested() {
  Bundle appSearchData = new Bundle();
  appSearchData.putString("SomeSpecificParam", SomeClass.class.getName());
  startSearch("", false, appSearchData, false);
  EditText  text = (EditText )findViewById(R.id.search_dialog_text);
  text.setHint("Search something else");
  return true;
}
</code>```

but text is equal null.

So looking forward you suggestions. Thanks.

答:
It looks like you're almost there.

The SearchDialog source does this to get the auto complete editable.

```<code>mSearchAutoComplete = (SearchAutoComplete) findViewById(com.android.internal.R.id.search_src_text);
</code>```

(note that the SearchAutoComplete class is a subclass of AutoCompleteTextView)

ContentLicense: CC BY-SA 2.5

Title: Set search hint dynamically

Body:
Does anybody knows how to set android search dialog hint dynamically?
T have try to do something like:

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
 android:label="@string/search_label"
 android:hint="@string/search_hint"
 android:id="@+id/search_dialog_text">
</searchable>

Somewhere:

@Override
public boolean onSearchRequested() {
  Bundle appSearchData = new Bundle();
  appSearchData.putString("SomeSpecificParam", SomeClass.class.getName());
  startSearch("", false, appSearchData, false);
  EditText  text = (EditText )findViewById(R.id.search_dialog_text);
  text.setHint("Search something else");
  return true;
}

but text is equal null.

So looking forward you suggestions. Thanks.

Body:
It looks like you're almost there.

The SearchDialog source does this to get the auto complete editable.

mSearchAutoComplete = (SearchAutoComplete) findViewById(com.android.internal.R.id.search_src_text);

(note that the SearchAutoComplete class is a subclass of AutoCompleteTextView)


问:
Name for pattern T | Array<T>
A common pattern that libraries use is accepting a type or an array of that type as an argument to a function. For example:

```<code>interface JQuery {
    add(selector: HTMLElement | HTMLElement[]): this;
}
</code>```

Is there a name for this pattern? I'd like to alias it to improve readability. My first guess is TypeOrArray<T> but this sounds clunky and may potentially be unintuitive.

Note: I've tagged this typescript since that's what I'm using and something idiomatic may be a better answer. However, this should apply to any language that makes use of generics.

答:
I don't think the pattern actually is "type or array of the type".

It's more like "whatever the author of the library considered to be convenient for its users".

Typescript union type fits pretty good here, it allows you to describe whatever combination of types is acceptable for particular function, without thinking too much about names.

If you inclined to name your types, the appropriate name could be

```<code>type HTMLElementsToAdd = HTMLElement | HTMLElement[];
</code>```

The purpose is to indicate that the type is not just an element array, and is specific to add method. Cursory look through jQuery API docs confirms that it hardly follows any specific pattern, and actually uses "or" to describe acceptable types, for example:

```<code>.append( content [, content ] )
 content
 Type: htmlString or Element or Text or Array or jQuery
</code>```

ContentLicense: CC BY-SA 3.0

Title: Name for pattern T | Array<T>

Body:
A common pattern that libraries use is accepting a type or an array of that type as an argument to a function. For example:

interface JQuery {
    add(selector: HTMLElement | HTMLElement[]): this;
}

Is there a name for this pattern? I'd like to alias it to improve readability. My first guess is TypeOrArray<T> but this sounds clunky and may potentially be unintuitive.

Note: I've tagged this typescript since that's what I'm using and something idiomatic may be a better answer. However, this should apply to any language that makes use of generics.

Body:
I don't think the pattern actually is "type or array of the type".

It's more like "whatever the author of the library considered to be convenient for its users".

Typescript union type fits pretty good here, it allows you to describe whatever combination of types is acceptable for particular function, without thinking too much about names.

If you inclined to name your types, the appropriate name could be

type HTMLElementsToAdd = HTMLElement | HTMLElement[];

The purpose is to indicate that the type is not just an element array, and is specific to add method. Cursory look through jQuery API docs confirms that it hardly follows any specific pattern, and actually uses "or" to describe acceptable types, for example:

.append( content [, content ] )
 content
 Type: htmlString or Element or Text or Array or jQuery


问:
Xml card layout
i trying to get a layout just like the image below for a game in android studio

currently my xml is

```<code><?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.dreacot.testmymemory.Game">

<ImageView
    android:id="@+id/imageView"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="53dp"
    tools:layout_editor_absoluteY="136dp" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="156dp"
    tools:layout_editor_absoluteY="136dp" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="266dp"
    tools:layout_editor_absoluteY="136dp" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="53dp"
    tools:layout_editor_absoluteY="285dp" />

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="156dp"
    tools:layout_editor_absoluteY="285dp" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="266dp"
    tools:layout_editor_absoluteY="285dp" />
</code>```

i want more cards to be added on the next level eg lvl 2
do i need to make several layouts for each level?

also i want each card to show its face when it is clicked

and finally i feel i am not doing the right thing as i feel xml files cannot be called into the gameplay is there a better way to do this layout(maybe programmatically)?

could anyone help?

答:
The way you are doing it is not the proper way to do it, In this way maybe you can achieve this for 6 cards. What if you have let's say 100 cards or may be 1000, will you add 100 images in Layout and get reference of 100 images in Activity and set Click Listeners and animations to turn the side on 100 images?

Use "GridView" and Adapter for your views, it will do your work with ease.

Check this:  https://developer.android.com/guide/topics/ui/layout/gridview.html

Title: Xml card layout

Body:
i trying to get a layout just like the image below for a game in android studio

currently my xml is

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.dreacot.testmymemory.Game">

<ImageView
    android:id="@+id/imageView"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="53dp"
    tools:layout_editor_absoluteY="136dp" />

<ImageView
    android:id="@+id/imageView4"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="156dp"
    tools:layout_editor_absoluteY="136dp" />

<ImageView
    android:id="@+id/imageView3"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="266dp"
    tools:layout_editor_absoluteY="136dp" />

<ImageView
    android:id="@+id/imageView6"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="53dp"
    tools:layout_editor_absoluteY="285dp" />

<ImageView
    android:id="@+id/imageView5"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="156dp"
    tools:layout_editor_absoluteY="285dp" />

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="72dp"
    android:layout_height="115dp"
    app:srcCompat="@drawable/backside"
    tools:layout_editor_absoluteX="266dp"
    tools:layout_editor_absoluteY="285dp" />

i want more cards to be added on the next level eg lvl 2
do i need to make several layouts for each level?

also i want each card to show its face when it is clicked

and finally i feel i am not doing the right thing as i feel xml files cannot be called into the gameplay is there a better way to do this layout(maybe programmatically)?

could anyone help?


问:
"Position: fixed" in CSS changes "justify-content-end"
I'm trying to make a navigation bar with the content on the right of the page. This worked until I added position:fixed in CSS. After I added position:fixed, the content got relocated to the left of the page. Can someone tell me why this happened?

.header {
  position: fixed;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="header">
  <ul class="nav nav-pills justify-content-end">
    <li class="active">About</li>
    <li> Portfolio</li>
    <li>Contact</li>
  </ul>
</div></code>```

答:
position: fixed; =
"Do not leave space for the element. Instead, position it at a specified position relative to the screen's viewport and don't move it when scrolled. When printing, position it at that fixed position on every page..." (source:
https://developer.mozilla.org/en-US/docs/Web/CSS/position?v=control)

Not sure what you want the final outcome to be, but check out your other positioning options: static, relative, absolute, fixed, sticky.

Body:
I'm trying to make a navigation bar with the content on the right of the page. This worked until I added position:fixed in CSS. After I added position:fixed, the content got relocated to the left of the page. Can someone tell me why this happened?

.header {
  position: fixed;
}

About

 Portfolio

Contact


问:
How to get previous position of a mesh
I'm trying to write a shader for doing the motionBlur effect in WebGL using three.js frameworks.
I'm trying to adapt  this tutorial for WebGL:
http://john-chapman-graphics.blogspot.fr/2013/01/per-object-motion-blur.html
and getting the velocity value with GPUComputeRenderer.

But i have problem for this line :

```<code>Position = uModelViewProjectionMat * gl_Vertex;
vPrevPosition = uPrevModelViewProjectionMat * gl_Vertex;
</code>```

How can i get or calculate the PrevModelViewProjectionMat ? I know it's projectionMatrice * modelViewMatrix * vec4(position, 1.0) but don't know how to get the previous projMatrix or previous modelViewMatrix. Can someone help?

答:
The previous projection matrix is probably going to be the same unless you modified the camera (near,far,fov).

The previous modelView matrix you need to calculate or save from the previous frame. Then provide it to the shader as a uniform, and do the transformation.

Title: How to get previous position of a mesh

Body:
I'm trying to write a shader for doing the motionBlur effect in WebGL using three.js frameworks.
I'm trying to adapt  this tutorial for WebGL:
http://john-chapman-graphics.blogspot.fr/2013/01/per-object-motion-blur.html
and getting the velocity value with GPUComputeRenderer.

But i have problem for this line :

Position = uModelViewProjectionMat * gl_Vertex;
vPrevPosition = uPrevModelViewProjectionMat * gl_Vertex;

How can i get or calculate the PrevModelViewProjectionMat ? I know it's projectionMatrice * modelViewMatrix * vec4(position, 1.0) but don't know how to get the previous projMatrix or previous modelViewMatrix. Can someone help?


问:
NSDateFormatter's init method is deprecated?
Per

http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Classes/NSDateFormatter_Class/Reference/Reference.html

The init method of NSDateFormatter is "Available in iPhone OS 2.0 through iPhone OS 3.2", and therefore not in 4.0.  Now, it certainly works, but this seems odd.  Is this is a mistake or is there some other way to create a NSDateFormatter?

答:
I would trust the header files over the documentation.

For example, Formatter Behaviors and OS Versions seems to contradict itself:

By default, on Mac OS X v10.4 instances of NSDateFormatter have the same behavior as they did on Mac OS X versions 10.0 to 10.3. On Mac OS X v10.5 and later, NSDateFormatter defaults to the 10.4+ behavior.

If you initialize a formatter using initWithDateFormat:allowNaturalLanguage:, you are (for backwards compatibility reasons) creating an “old-style” date formatter. To use the new behavior, you initialize the formatter with init. If necessary, you can set the default class behavior using setDefaultFormatterBehavior:), you can set the behavior for an instance using setFormatterBehavior: message with the argument NSDateFormatterBehavior10_4.

It sounds like initWithDateFormat:allowNaturalLanguage: is actually the deprecated method?


问:
WARNING : No target specified, deploying to emulator
I'm trying to run an ionic app on my mobile phone (Android 4.4.2).
USB-Debugging is activated.

When i run the command "ionic emulate android" everything works fine and the app is opend in the emulator.

But when I run the commad "ionic run android" I get following warning:

WARNING : No target specified, deploying to emulator

and the app is started on the virtual device...

Shouldn't the app run on my mobile phone? What am I doing wrong?
How can I specify the target?

P.S.: When I copy the .apk file to the phone I can run the app.

答:
None of these worked for me on android 6.0 on a mac.

I found this article: http://trendblog.net/android-file-transfer-not-working/

quoting from it:

Enable Developer Mode by going to Settings > About Phone (at the very bottom usually) > press on Build Number repeatedly until the pop-up appears

Go to Settings > Developer Options

Enable USB debugging


问:
on press button mass stay the color
Hi can some one please help me with this code

```<code>horse_btn_a1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      horse_btn_a1.setBackgroundColor(Color.parseColor("@drawable/ront2"));
    }
});
</code>```

and what I wanna do is when the button is pressed it must stay that color.

答:
Hee, use hex color "#ffffff" with parseColor
    horse_btn_a1.setBackgroundColor(Color.parseColor("#ffffff"));

Hope I help

Title: on press button mass stay the color

Body:
Hi can some one please help me with this code

horse_btn_a1.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
      horse_btn_a1.setBackgroundColor(Color.parseColor("@drawable/ront2"));
    }
});

and what I wanna do is when the button is pressed it must stay that color.


问:
Count the number of null values into an Oracle table?
I need to count the number of null values of all the columns in a table in Oracle.

For instance, I execute the following statements to create a table TEST and insert data.

```<code> CREATE TABLE TEST
 (  A VARCHAR2(20 BYTE),
    B VARCHAR2(20 BYTE),
    C VARCHAR2(20 BYTE)
  );
Insert into TEST (A) values ('a');
Insert into TEST (B) values ('b');
Insert into TEST (C) values ('c');
</code>```

Now, I write the following code to compute the number of null values in the table TEST:

```<code>declare
cnt number :=0;
temp number :=0;
begin
  for r in ( select column_name, data_type
             from    user_tab_columns
             where table_name = upper('test')
             order by column_id )
  loop
      if r.data_type <> 'NOT NULL' then
         select count(*) into temp FROM TEST where r.column_name IS NULL;
         cnt := cnt + temp;
      END IF;
  end loop;
   dbms_output.put_line('Total: '||cnt);
end;
/
</code>```

It returns 0, when the expected value is 6.

Where is the error?

Thanks in advance.

答:
Counting NULLs for each column

In order to count NULL values for all columns of a table T you could run

```<code>SELECT COUNT(*) - COUNT(col1) col1_nulls
     , COUNT(*) - COUNT(col2) col2_nulls
     ,..
     , COUNT(*) - COUNT(colN) colN_nulls
     , COUNT(*) total_rows
FROM   T
/
</code>```

Where col1, col2, .., colN should be replaced with actual names of columns of T table.

Aggregate functions -like COUNT()- ignore NULL values, so COUNT(*) - COUNT(col) will give you how many nulls for each column.

Summarize all NULLs of a table

If you want to know how many fields are NULL, I mean every NULL of every record you can

```<code>WITH d as (
    SELECT COUNT(*) - COUNT(col1) col1_nulls
         , COUNT(*) - COUNT(col2) col2_nulls
         ,..
         , COUNT(*) - COUNT(colN) colN_nulls
         , COUNT(*) total_rows
    FROM   T
) SELECT col1_nulls + col1_nulls +..+ colN_null
  FROM d
/
</code>```

Summarize all NULLs of a table (using Oracle dictionary tables)

Following is an improvement in which you need to now nothing but table name and it is very easy to code a function based on it

```<code>DECLARE
  T    VARCHAR2(64) := '<YOUR TABLE NAME>';
  expr VARCHAR2(32767);
  q    INTEGER;
BEGIN
  SELECT 'SELECT /*+FULL(T) PARALLEL(T)*/' || COUNT(*) || ' * COUNT(*) OVER () - ' || LISTAGG('COUNT(' || COLUMN_NAME || ')', ' + ') WITHIN GROUP (ORDER BY COLUMN_ID) || ' FROM ' || T
  INTO   expr
  FROM   USER_TAB_COLUMNS
  WHERE  TABLE_NAME = T;

  -- This line is for debugging purposes only
  DBMS_OUTPUT.PUT_LINE(expr);

  EXECUTE IMMEDIATE expr INTO q;

  DBMS_OUTPUT.PUT_LINE(q);
END;
/
</code>```

Due to calculation implies a full table scan, code produced in expr variable was optimized for parallel running.

User defined function null_fields

Function version, also includes an optional parameter  to be able to run on other schemas.

```<code>CREATE OR REPLACE FUNCTION null_fields(table_name IN VARCHAR2, owner IN VARCHAR2 DEFAULT USER)
  RETURN INTEGER IS
  T    VARCHAR2(64) := UPPER(table_name);
  o    VARCHAR2(64) := UPPER(owner);
  expr VARCHAR2(32767);
  q    INTEGER;
BEGIN
  SELECT 'SELECT /*+FULL(T) PARALLEL(T)*/' || COUNT(*) || ' * COUNT(*) OVER () - ' || listagg('COUNT(' || column_name || ')', ' + ') WITHIN GROUP (ORDER BY column_id) || ' FROM ' || o || '.' || T || ' t'
  INTO   expr
  FROM   all_tab_columns
  WHERE  table_name = T;

  EXECUTE IMMEDIATE expr INTO q;

  RETURN q;
END;
/

-- Usage 1
SELECT null_fields('<your table name>') FROM dual
/

-- Usage 2
SELECT null_fields('<your table name>', '<table owner>') FROM dual
/
</code>```

Body:
I need to count the number of null values of all the columns in a table in Oracle.

For instance, I execute the following statements to create a table TEST and insert data.

 CREATE TABLE TEST
 (  A VARCHAR2(20 BYTE),
    B VARCHAR2(20 BYTE),
    C VARCHAR2(20 BYTE)
  );
Insert into TEST (A) values ('a');
Insert into TEST (B) values ('b');
Insert into TEST (C) values ('c');

Now, I write the following code to compute the number of null values in the table TEST:

declare
cnt number :=0;
temp number :=0;
begin
  for r in ( select column_name, data_type
             from    user_tab_columns
             where table_name = upper('test')
             order by column_id )
  loop
      if r.data_type <> 'NOT NULL' then
         select count(*) into temp FROM TEST where r.column_name IS NULL;
         cnt := cnt + temp;
      END IF;
  end loop;
   dbms_output.put_line('Total: '||cnt);
end;
/

It returns 0, when the expected value is 6.

Where is the error?

Thanks in advance.

Body:
Counting NULLs for each column

In order to count NULL values for all columns of a table T you could run

SELECT COUNT(*) - COUNT(col1) col1_nulls
     , COUNT(*) - COUNT(col2) col2_nulls
     ,..
     , COUNT(*) - COUNT(colN) colN_nulls
     , COUNT(*) total_rows
FROM   T
/

Where col1, col2, .., colN should be replaced with actual names of columns of T table.

Aggregate functions -like COUNT()- ignore NULL values, so COUNT(*) - COUNT(col) will give you how many nulls for each column.

Summarize all NULLs of a table

If you want to know how many fields are NULL, I mean every NULL of every record you can

WITH d as (
    SELECT COUNT(*) - COUNT(col1) col1_nulls
         , COUNT(*) - COUNT(col2) col2_nulls
         ,..
         , COUNT(*) - COUNT(colN) colN_nulls
         , COUNT(*) total_rows
    FROM   T
) SELECT col1_nulls + col1_nulls +..+ colN_null
  FROM d
/

Summarize all NULLs of a table (using Oracle dictionary tables)

Following is an improvement in which you need to now nothing but table name and it is very easy to code a function based on it

DECLARE
  T    VARCHAR2(64) := '<YOUR TABLE NAME>';
  expr VARCHAR2(32767);
  q    INTEGER;
BEGIN
  SELECT 'SELECT /*+FULL(T) PARALLEL(T)*/' || COUNT(*) || ' * COUNT(*) OVER () - ' || LISTAGG('COUNT(' || COLUMN_NAME || ')', ' + ') WITHIN GROUP (ORDER BY COLUMN_ID) || ' FROM ' || T
  INTO   expr
  FROM   USER_TAB_COLUMNS
  WHERE  TABLE_NAME = T;

  -- This line is for debugging purposes only
  DBMS_OUTPUT.PUT_LINE(expr);

  EXECUTE IMMEDIATE expr INTO q;

  DBMS_OUTPUT.PUT_LINE(q);
END;
/

Due to calculation implies a full table scan, code produced in expr variable was optimized for parallel running.

User defined function null_fields

Function version, also includes an optional parameter  to be able to run on other schemas.

CREATE OR REPLACE FUNCTION null_fields(table_name IN VARCHAR2, owner IN VARCHAR2 DEFAULT USER)
  RETURN INTEGER IS
  T    VARCHAR2(64) := UPPER(table_name);
  o    VARCHAR2(64) := UPPER(owner);
  expr VARCHAR2(32767);
  q    INTEGER;
BEGIN
  SELECT 'SELECT /*+FULL(T) PARALLEL(T)*/' || COUNT(*) || ' * COUNT(*) OVER () - ' || listagg('COUNT(' || column_name || ')', ' + ') WITHIN GROUP (ORDER BY column_id) || ' FROM ' || o || '.' || T || ' t'
  INTO   expr
  FROM   all_tab_columns
  WHERE  table_name = T;

  EXECUTE IMMEDIATE expr INTO q;

  RETURN q;
END;
/

-- Usage 1
SELECT null_fields('<your table name>') FROM dual
/

-- Usage 2
SELECT null_fields('<your table name>', '<table owner>') FROM dual
/


问:
How to create .htaccess to display SVG's?
I'm testing a website that has worked great locally however when I upload it to my godaddy server my SVG's are not rendering in browser.

After some web searches and working with tech support I learned I need to have a .htaccess file configured in my image folder directory to correctly display SVG's.

Can someone please let me know how to create, download, or copy and paste the correct data for a .htaccess?

答:
I guess you mean setting a proper Content-Type header. The MIME type is apparently image/svg+xml and you can use the AddType directive:

```<code># Add one line for each extension
AddType image/svg+xml .svg
</code>```

Body:
I guess you mean setting a proper Content-Type header. The MIME type is apparently image/svg+xml and you can use the AddType directive:

# Add one line for each extension
AddType image/svg+xml .svg


问:
Create index to speed up query with inner join
I am using MS SQL and have two tables: Products (ProdID, some other fields) and ProdCat (ID, ProdID, CategoryID) which determines which Product belongs to which category.

And I am making select like

```<code>SELECT TOP (8) ProdID, Description, Image
FROM  Products INNER JOIN ProdCat ON ProdCat.ProdID = Products.ProdID
WHERE  Products.Active=1 AND ProdCat.CategoryID = 123 Order by ProdCat.sorting, Products.ProdID
</code>```

Products table has more than 50.000 and ProdCat table has more than 150.000 records and the query is slow.

Can you please advise how to create index to speed up this query?

Thanks.

答:
This is your query:

```<code>SELECT TOP (8) ProdID, Description, Image
FROM Products p INNER JOIN
     ProdCat pc
     ON pc.ProdID = p.ProdID
WHERE  p.Active = 1 AND pc.CategoryID = 123
Order by pc.sorting, p.ProdID;
</code>```

This is a bit challenging because there are two ways the query could be optimized.  First try ProdCat(CategoryId, ProdId) and Products(ProdId, Active).

Unfortunately, neither is going o eliminate the ordering.  But this might improve performance.

Body:
I am using MS SQL and have two tables: Products (ProdID, some other fields) and ProdCat (ID, ProdID, CategoryID) which determines which Product belongs to which category.

And I am making select like

SELECT TOP (8) ProdID, Description, Image
FROM  Products INNER JOIN ProdCat ON ProdCat.ProdID = Products.ProdID
WHERE  Products.Active=1 AND ProdCat.CategoryID = 123 Order by ProdCat.sorting, Products.ProdID

Products table has more than 50.000 and ProdCat table has more than 150.000 records and the query is slow.

Can you please advise how to create index to speed up this query?

Thanks.

Body:
This is your query:

SELECT TOP (8) ProdID, Description, Image
FROM Products p INNER JOIN
     ProdCat pc
     ON pc.ProdID = p.ProdID
WHERE  p.Active = 1 AND pc.CategoryID = 123
Order by pc.sorting, p.ProdID;

This is a bit challenging because there are two ways the query could be optimized.  First try ProdCat(CategoryId, ProdId) and Products(ProdId, Active).

Unfortunately, neither is going o eliminate the ordering.  But this might improve performance.


问:
Kotlin: Pass and consume a 2 parameter function?
I'm trying to learn functional programming in Kotlin and am having difficulty making this code work:

```<code>import java.util.*

fun caseName(br: String, c: Int): String {
  if (c == 0) {
    return br.toLowerCase()
    } else {
    return br.toUpperCase()
    }
}
fun mapIt(ns: ArrayList<String>, f: (String, Int) -> String): List<String> {
  val coll: List<String> = ns.map {it -> f(it, _)}
  return coll
}

fun main(args: Array<String>) {
  val names = arrayListOf("Joe", "Bill", "Murrary")
  val cased = mapIt(names, (::caseName)(_, 0))
  println(cased.first())
}
</code>```

How do I get mapIt to recognize the case flag when mapping over the list?

Thank you!

EDIT: The case above is a simplified version of the following, which does not work either...

```<code>data class Borrower(val name: String, val maxBooks: Int) {
    companion object {

        fun getName(br: Borrower, c: Int): String {
          if (c == 0) {
            return br.name.toLowerCase()
            } else {
            return br.name.toUpperCase()
            }
        }

        fun findBorrower(n: String, brs: ArrayList<Borrower>, f: (Borrower) -> String): Borrower? {
            val coll: List<Borrower> = brs.filter { it -> f(it) == n }
            if (coll.isEmpty()) {
                return null
            } else return coll.first()
        }
    }
}

fun main(args: Array<String>) {
    val br1 = Borrower(name = "Borrower1", maxBooks = 1)
    val br2 = Borrower(name = "Borrower2", maxBooks = 2)
    val br3 = Borrower(name = "Borrower3", maxBooks = 3)
    val br4 = Borrower(name = "borrower4", maxBooks = 4)
    val br5 = Borrower(name = "BORROWER5", maxBooks = 5)
    val brs1 = arrayListOf(br1, br2, br3, br4, br5)

    val c = Borrower.findBorrower("borrower3", brs1, {Borrower.Companion::getName(it, 0)})
    println(c)
}
</code>```

答:
There are a couple of issues here:

Your objectives are contradictory here - you want mapIt to take a 2-arg function, but it also looks like you're trying to perform a partial application of caseName, which would of course result in a 1-arg function.

Underscores don't do what you think in Kotlin (it looks like maybe you come from a Scala background?).

It looks like you want something either like this:

```<code>// f is a *single*-arg function
fun mapIt(ns: ArrayList<String>, f: (String) -> String): List<String> {
    return ns.map(f)
}

fun main(args: Array<String>) {
    val names = arrayListOf("Joe", "Bill", "Murrary")
    val cased = mapIt(names, { caseName(it, 0) })  // Partial application
    println(cased.first())
}
</code>```

or like this:

```<code>// f is a two-arg function
fun mapIt(ns: ArrayList<String>, f: (String, Int) -> String): List<String> {
    return ns.map { f(it, 0) }
}

fun main(args: Array<String>) {
    val names = arrayListOf("Joe", "Bill", "Murrary")
    val cased = mapIt(names, ::caseName)
    println(cased.first())
}
</code>```

Body:
I'm trying to learn functional programming in Kotlin and am having difficulty making this code work:

import java.util.*

fun caseName(br: String, c: Int): String {
  if (c == 0) {
    return br.toLowerCase()
    } else {
    return br.toUpperCase()
    }
}
fun mapIt(ns: ArrayList<String>, f: (String, Int) -> String): List<String> {
  val coll: List<String> = ns.map {it -> f(it, _)}
  return coll
}

fun main(args: Array<String>) {
  val names = arrayListOf("Joe", "Bill", "Murrary")
  val cased = mapIt(names, (::caseName)(_, 0))
  println(cased.first())
}

How do I get mapIt to recognize the case flag when mapping over the list?

Thank you!

EDIT: The case above is a simplified version of the following, which does not work either...

data class Borrower(val name: String, val maxBooks: Int) {
    companion object {

        fun getName(br: Borrower, c: Int): String {
          if (c == 0) {
            return br.name.toLowerCase()
            } else {
            return br.name.toUpperCase()
            }
        }

        fun findBorrower(n: String, brs: ArrayList<Borrower>, f: (Borrower) -> String): Borrower? {
            val coll: List<Borrower> = brs.filter { it -> f(it) == n }
            if (coll.isEmpty()) {
                return null
            } else return coll.first()
        }
    }
}

fun main(args: Array<String>) {
    val br1 = Borrower(name = "Borrower1", maxBooks = 1)
    val br2 = Borrower(name = "Borrower2", maxBooks = 2)
    val br3 = Borrower(name = "Borrower3", maxBooks = 3)
    val br4 = Borrower(name = "borrower4", maxBooks = 4)
    val br5 = Borrower(name = "BORROWER5", maxBooks = 5)
    val brs1 = arrayListOf(br1, br2, br3, br4, br5)

    val c = Borrower.findBorrower("borrower3", brs1, {Borrower.Companion::getName(it, 0)})
    println(c)
}

Body:
There are a couple of issues here:

Your objectives are contradictory here - you want mapIt to take a 2-arg function, but it also looks like you're trying to perform a partial application of caseName, which would of course result in a 1-arg function.

Underscores don't do what you think in Kotlin (it looks like maybe you come from a Scala background?).

It looks like you want something either like this:

// f is a *single*-arg function
fun mapIt(ns: ArrayList<String>, f: (String) -> String): List<String> {
    return ns.map(f)
}

fun main(args: Array<String>) {
    val names = arrayListOf("Joe", "Bill", "Murrary")
    val cased = mapIt(names, { caseName(it, 0) })  // Partial application
    println(cased.first())
}

or like this:

// f is a two-arg function
fun mapIt(ns: ArrayList<String>, f: (String, Int) -> String): List<String> {
    return ns.map { f(it, 0) }
}

fun main(args: Array<String>) {
    val names = arrayListOf("Joe", "Bill", "Murrary")
    val cased = mapIt(names, ::caseName)
    println(cased.first())
}


问:
How can I increment last byte of 32bits key in python?
I am having difficulty figuring out how to increment the last byte of 32bits key.
For example value of key is
key = b"3333"*8</p>

答:
This may help</p>

```<code>def inc(v):
    nope = lambda x: x
    def increment(vv):
        tmp = vv
        if increment.i == 1:
            tmp = 1+increment.to_int(vv)
            increment.i = tmp / 256
            tmp = increment.to_char(tmp%256)
        return tmp
    increment.to_char = chr if (type(v) == str) else nope
    increment.to_int = ord if (type(v) == str) else nope
    increment.i = 1
    return map(increment, v[::-1])[::-1]
</code>```

Body:
This may help

def inc(v):
    nope = lambda x: x
    def increment(vv):
        tmp = vv
        if increment.i == 1:
            tmp = 1+increment.to_int(vv)
            increment.i = tmp / 256
            tmp = increment.to_char(tmp%256)
        return tmp
    increment.to_char = chr if (type(v) == str) else nope
    increment.to_int = ord if (type(v) == str) else nope
    increment.i = 1
    return map(increment, v[::-1])[::-1]


问:
Swap two blocks of text programatically
I have an XML file made up of multiple blocks that are very similar. Here are two:

```<code>    <Grid Name="EMFieldMany" GridType="Uniform">
        <Topology TopologyType="3DRectMesh" Dimensions="40 40 40 "/>
        <Attribute AttributeType="Scalar" Name="Er" Center="Node">
            <DataItem Dimensions="40 40 40 " NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/field/Er-0
            </DataItem>
        </Attribute>
        <Geometry GeometryType="VXVYVZ">
            <DataItem Name="r" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/r
            </DataItem>
            <DataItem Name="theta" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/theta
            </DataItem>
            <DataItem Name="z" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/z
            </DataItem>
        </Geometry>
    </Grid>
    <Grid Name="EMFieldMany" GridType="Uniform">
        <Topology TopologyType="3DRectMesh" Dimensions="40 40 40 "/>
        <Attribute AttributeType="Scalar" Name="Er" Center="Node">
            <DataItem Dimensions="40 40 40 " NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/field/Er-1
            </DataItem>
        </Attribute>
        <Geometry GeometryType="VXVYVZ">
            <DataItem Name="r" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/r
            </DataItem>
            <DataItem Name="theta" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/theta
            </DataItem>
            <DataItem Name="z" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/z
            </DataItem>
        </Geometry>
    </Grid>
</code>```

Typically I have hundreds of similar <Grid> objects in a single file. Now, I want to programatically swap the positions of the <DataItem Name="r"> and <DataItem Name="z"> blocks in each <Grid> object such that the <DataItem>s are in the order z, theta, r. Also, for each Dimensions=" x y z " statement, each Dimensions attribute that contains three values, I want the attribute to be rewritten as Dimensions=" z y x ".

I don't really mind the programming language being used to do this. I'm on a Linux workstation with bash, python, perl... all the standard stuff.

EDIT: This answer uses sed to match blocks of text, but I'm not sure how to manipulate the selected block afterwards. This other answer swaps single lines up and down, but I'm not sure how to generalize to blocks of text, and to make it swap blocks.

答:
This can be easily done with ed:

```<code>g/<DataItem Name="r"/-ka\
/<DataItem Name="z"/\
-kb\
.,/\/DataItem/m'a\
+1,/\/DataItem/m'b
</code>```

Title: Swap two blocks of text programatically

Body:
I have an XML file made up of multiple blocks that are very similar. Here are two:

    <Grid Name="EMFieldMany" GridType="Uniform">
        <Topology TopologyType="3DRectMesh" Dimensions="40 40 40 "/>
        <Attribute AttributeType="Scalar" Name="Er" Center="Node">
            <DataItem Dimensions="40 40 40 " NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/field/Er-0
            </DataItem>
        </Attribute>
        <Geometry GeometryType="VXVYVZ">
            <DataItem Name="r" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/r
            </DataItem>
            <DataItem Name="theta" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/theta
            </DataItem>
            <DataItem Name="z" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/z
            </DataItem>
        </Geometry>
    </Grid>
    <Grid Name="EMFieldMany" GridType="Uniform">
        <Topology TopologyType="3DRectMesh" Dimensions="40 40 40 "/>
        <Attribute AttributeType="Scalar" Name="Er" Center="Node">
            <DataItem Dimensions="40 40 40 " NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/field/Er-1
            </DataItem>
        </Attribute>
        <Geometry GeometryType="VXVYVZ">
            <DataItem Name="r" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/r
            </DataItem>
            <DataItem Name="theta" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/theta
            </DataItem>
            <DataItem Name="z" Dimensions="40" NumberType="Float" Precision="8" Format="HDF5" Endian="Big">
                Field_reflected_time_3D.hdf5:/coordinates/z
            </DataItem>
        </Geometry>
    </Grid>

Typically I have hundreds of similar <Grid> objects in a single file. Now, I want to programatically swap the positions of the <DataItem Name="r"> and <DataItem Name="z"> blocks in each <Grid> object such that the <DataItem>s are in the order z, theta, r. Also, for each Dimensions=" x y z " statement, each Dimensions attribute that contains three values, I want the attribute to be rewritten as Dimensions=" z y x ".

I don't really mind the programming language being used to do this. I'm on a Linux workstation with bash, python, perl... all the standard stuff.

EDIT: This answer uses sed to match blocks of text, but I'm not sure how to manipulate the selected block afterwards. This other answer swaps single lines up and down, but I'm not sure how to generalize to blocks of text, and to make it swap blocks.

Body:
This can be easily done with ed:

g/<DataItem Name="r"/-ka\
/<DataItem Name="z"/\
-kb\
.,/\/DataItem/m'a\
+1,/\/DataItem/m'b


问:
Trying to upload images to my database in CodeIgniter with a button but I'm getting an error
I'm trying to make a function in CodeIgniter (PHP) so users can add images to my database but I'm getting an error when I try to upload an image.. The picture does get in my upload folder but it doesn't  upload in my phpmyadmin table row.

I'm using phpMyAdmin

Database name: kadokado

Table name: products

Table row name where i want to put these images to: product_foto

image folder: upload

My controller file (Product.php):

```<code>    class Product extends CI_Controller {

    var $data = array();

       public function __construct()
 {
  parent::__construct();
 }

}

     public function index()
 {
  $config = array (
   'upload_path' => 'upload/',
   'allowed_types' => 'jpg|jpeg|png|bmp',
   'max_size' => 0,
   'filename' => url_title($this->input->post('file'))

   );
   $this->load->library('upload', $config);

   if ($this->upload->do_upload('file')) {
    $this->db->insert('products', array(
        'product_foto' => $this->upload->product_foto
     ));
     $this->session->set_flashdata('msg', 'Success');
   }

  $this->load->view('product_form', $this->data);
 }
</code>```

}

This is my view file (product_form.php) :

```<code><?php
echo $this->session->flashdata('msg');
echo form_open_multipart();
echo form_upload('file');
echo form_submit('upload', 'Upload');
echo form_close();
?>
</code>```

And these are the errors I'm getting:`

```<code>  A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Upload::$product_foto

Filename: controllers/Product.php

Line Number: 21

Backtrace:

File: /home/ubuntu/workspace/application/controllers/Product.php
Line: 21
Function: _error_handler

File: /home/ubuntu/workspace/index.php
Line: 315
Function: require_once

A Database Error Occurred

Error Number: 1048

Column 'product_foto' cannot be null

INSERT INTO `products` (`product_foto`) VALUES (NULL)

Filename: controllers/Product.php

Line Number: 22
</code>```

答:
Try this function </p>

```<code>public function index() {
  $data = array();

  $config = array(
      'upload_path' => 'upload',
      'allowed_types' => 'jpg|jpeg|png|bmp',
      'max_size' => 250,
      'max_width' => 1920,
      'max_heigh' => 1080,
  );
 $this->load->library('upload', $config);

 if (!$this->upload->do_upload('userfile')) {

   $error = array('error' => $this->upload->display_errors());
   // var_dump( $error); die; check errors
 } else {
   $fileName = $this->upload->data();
   $data['product_foto'] = $fileName['file_name'];
   $this->db->insert('products', $data);
   $this->session->set_flashdata('msg', 'Success');
 }
   $this->load->view('product_form');
}
</code>```

Body:
I'm trying to make a function in CodeIgniter (PHP) so users can add images to my database but I'm getting an error when I try to upload an image.. The picture does get in my upload folder but it doesn't  upload in my phpmyadmin table row.

I'm using phpMyAdmin

Database name: kadokado

Table name: products

Table row name where i want to put these images to: product_foto

image folder: upload

My controller file (Product.php):

    class Product extends CI_Controller {

    var $data = array();

       public function __construct()
 {
  parent::__construct();
 }

}

     public function index()
 {
  $config = array (
   'upload_path' => 'upload/',
   'allowed_types' => 'jpg|jpeg|png|bmp',
   'max_size' => 0,
   'filename' => url_title($this->input->post('file'))

   );
   $this->load->library('upload', $config);

   if ($this->upload->do_upload('file')) {
    $this->db->insert('products', array(
        'product_foto' => $this->upload->product_foto
     ));
     $this->session->set_flashdata('msg', 'Success');
   }

  $this->load->view('product_form', $this->data);
 }

}

This is my view file (product_form.php) :

<?php
echo $this->session->flashdata('msg');
echo form_open_multipart();
echo form_upload('file');
echo form_submit('upload', 'Upload');
echo form_close();
?>

And these are the errors I'm getting:`

  A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Upload::$product_foto

Filename: controllers/Product.php

Line Number: 21

Backtrace:

File: /home/ubuntu/workspace/application/controllers/Product.php
Line: 21
Function: _error_handler

File: /home/ubuntu/workspace/index.php
Line: 315
Function: require_once

A Database Error Occurred

Error Number: 1048

Column 'product_foto' cannot be null

INSERT INTO `products` (`product_foto`) VALUES (NULL)

Filename: controllers/Product.php

Line Number: 22

Body:
Try this function

public function index() {
  $data = array();

  $config = array(
      'upload_path' => 'upload',
      'allowed_types' => 'jpg|jpeg|png|bmp',
      'max_size' => 250,
      'max_width' => 1920,
      'max_heigh' => 1080,
  );
 $this->load->library('upload', $config);

 if (!$this->upload->do_upload('userfile')) {

   $error = array('error' => $this->upload->display_errors());
   // var_dump( $error); die; check errors
 } else {
   $fileName = $this->upload->data();
   $data['product_foto'] = $fileName['file_name'];
   $this->db->insert('products', $data);
   $this->session->set_flashdata('msg', 'Success');
 }
   $this->load->view('product_form');
}


问:
PHP running 1 query for multiple variables from array
Using the below code in an attempt to run a single query with exploded array variables:

```<code> <?php
 $containers = $_POST['cntnum'];
 $containersArray = preg_replace('/\n$/','',preg_replace('/^\n/','',preg_replace('/[\r\n]+/',"\n",$containers)));
 $count = count($containersArray);

 for($i = 0; $i < $count; $i++)
 {
   $container = $containersArray[$i];
   $cntFixed = "'".$container."',";
 }

 $select = "SELECT container, date, pool FROM inventory WHERE container IN (".$ctnFixed.")";

 $query = mysqli_query($dbc, $select) or die(mysqli_error());

 ?>
</code>```

When I pass $cntFixed into the query.  I don't get all of the variables that were in the array.  Instead, I only get the last of the variables with an ending comma, as shown when I print to the console here:

```<code>  "SELECT container, date, pool FROM inventory WHERE container IN ('variable3',)"
</code>```

Of course, the ending comma will throw the query off, so I need to take that into consideration.

I cannot put the query into the for loop, because that runs the query the same amount of times as the array count.

What I need to do is run the query 1 time with all of the variables passed into the query.

The query should look like this when I print it to the console:

```<code> "SELECT container, date, pool FROM inventory WHERE container IN ('variable1', 'variable2', 'variable3')"
</code>```

答:
The easiest way to do this is to create an array, then implode it into a string. You seem to already have your data in $containersArray, so use that, unless you need to build another array for some reason. Then add it in like this:

```<code> $select = "SELECT container, date, pool FROM inventory WHERE container IN ('".implode("','",$containersArray."')";
</code>```

Please note this is not secure and can open you up to both SQL injection and nasty quoting issues. Instead, use prepared statements, and you can build up the placeholders the same way.

ContentLicense: CC BY-SA 4.0

Body:
Using the below code in an attempt to run a single query with exploded array variables:

 <?php
 $containers = $_POST['cntnum'];
 $containersArray = preg_replace('/\n$/','',preg_replace('/^\n/','',preg_replace('/[\r\n]+/',"\n",$containers)));
 $count = count($containersArray);

 for($i = 0; $i < $count; $i++)
 {
   $container = $containersArray[$i];
   $cntFixed = "'".$container."',";
 }

 $select = "SELECT container, date, pool FROM inventory WHERE container IN (".$ctnFixed.")";

 $query = mysqli_query($dbc, $select) or die(mysqli_error());

 ?>

When I pass $cntFixed into the query.  I don't get all of the variables that were in the array.  Instead, I only get the last of the variables with an ending comma, as shown when I print to the console here:

  "SELECT container, date, pool FROM inventory WHERE container IN ('variable3',)"

Of course, the ending comma will throw the query off, so I need to take that into consideration.

I cannot put the query into the for loop, because that runs the query the same amount of times as the array count.

What I need to do is run the query 1 time with all of the variables passed into the query.

The query should look like this when I print it to the console:

 "SELECT container, date, pool FROM inventory WHERE container IN ('variable1', 'variable2', 'variable3')"

Body:
The easiest way to do this is to create an array, then implode it into a string. You seem to already have your data in $containersArray, so use that, unless you need to build another array for some reason. Then add it in like this:

 $select = "SELECT container, date, pool FROM inventory WHERE container IN ('".implode("','",$containersArray."')";

Please note this is not secure and can open you up to both SQL injection and nasty quoting issues. Instead, use prepared statements, and you can build up the placeholders the same way.