Connect to an API


#1

Hi?

I am developing an App and trying to load data from an API to my ListView .
It seems everything’s ok because it does not give/ return any error.

BUT
when I click the button to open the page (my html component) it does not open and does not say anything.
The Api is working well and the data is accessible, i tested on the browser. I REALLY DON’T KNOW WHAT TO DO BECAUSE IT DOES NOT SAY ANYTHING!

ANY HELP, PLEASE?


#2

There are plenty of examples in docs and forums for calling a service. So without some code / playground where your issue can be reproduced, it’s not possible to judge what could be the issue here.


#3

SIR now i can see the out put:

An uncaught Exception occurred on “main” thread.
com.tns.NativeScriptException:
Calling js method onViewAttachedToWindow failed

Error: java.lang.IllegalStateException: Activity has been destroyed
android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1456)
android.app.BackStackRecord.commitInternal(BackStackRecord.java:708)
android.app.BackStackRecord.commit(BackStackRecord.java:672)
com.tns.Runtime.callJSMethodNative(Native Method)
com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
com.tns.Runtime.callJSMethod(Runtime.java:983)
com.tns.Runtime.callJSMethod(Runtime.java:967)
com.tns.Runtime.callJSMethod(Runtime.java:959)
com.tns.gen.java.lang.Object_frame_32_36_AttachListener.onViewAttachedToWindow(Object_frame_32_36_AttachListener.java:17)
android.view.View.dispatchAttachedToWindow(View.java:15520)
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2916)
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1526)
android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
android.view.Choreographer.doCallbacks(Choreographer.java:686)
android.view.Choreographer.doFrame(Choreographer.java:621)
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
android.os.Handler.handleCallback(Handler.java:751)
android.os.Handler.dispatchMessage(Handler.java:95)
android.os.Looper.loop(Looper.java:154)
android.app.ActivityThread.main(ActivityThread.java:6119)
java.lang.reflect.Method.invoke(Native Method)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
File: "file:///data/data/org.nativescript.lambda/files/app/tns_modules/tns-core-modules/ui/frame/frame.js, line: 256, column: 20

StackTrace:
Frame: function:‘Frame._navigateCore’, file:‘file:///data/data/org.nativescript.lambda/files/app/tns_modules/tns-core-modules/ui/frame/frame.js’, line: 256, column: 21
Frame: function:‘Frame._processNextNavigationEntry’, file:‘file:///data/data/org.nativescript.lambda/files/app/tns_modules/tns-core-modules/ui/frame/frame.js’, line: 134, column: 18
Frame: function:‘Frame._onAttachedToWindow’, file:‘file:///data/data/org.nativescript.lambda/files/app/tns_modules/tns-core-modules/ui/frame/frame.js’, line: 114, column: 14
Frame: function:‘AttachListener.onViewAttachedToWindow’, file:‘file:///data/data/org.nativescript.lambda/files/app/tns_modules/tns-core-modules/ui/frame/frame.js’, line: 38, column: 27

at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1116)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:996)
at com.tns.Runtime.callJSMethod(Runtime.java:983)
at com.tns.Runtime.callJSMethod(Runtime.java:967)
at com.tns.Runtime.callJSMethod(Runtime.java:959)
at com.tns.gen.java.lang.Object_frame_32_36_AttachListener.onViewAttachedToWindow(Object_frame_32_36_AttachListener.java:17)
at android.view.View.dispatchAttachedToWindow(View.java:15520)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2916)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2923)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1526)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

Caused by: java.lang.IllegalStateException: Activity has been destroyed
at android.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1456)
at android.app.BackStackRecord.commitInternal(BackStackRecord.java:708)
at android.app.BackStackRecord.commit(BackStackRecord.java:672)
… 28 more