Accessing Android API from NativeScript+Vue

android

#1

I am attempting to interface with an Android class.Specifically, I’m looking to use the android.view.View.OnLongClickListener

I have referenced a relevant doc. Examples and projects that do this appear to have android as a global variable injected. However, this variable does not appear callable from my Vue component.

Any help would be appreciated.


#2

Vue / Angular are just a pattern to write your code and end of the day everything is just JavaScript. If you find something doesn’t work, I would highly recommend you to create a playground example to demonstrate your issue to others so they can guide and help you.


#3

It appears that the android variable is not available within Vue components (in my project anyways). However, it is available in the context main.js file.

My solution to my issue was to append the variable to the Vue prototype. It is now accessible from within the component code.

I suspect that the loader may be doing something that impacts the scope, but there doesn’t appear to be documentation that guarantees that the variable is available from within components.


#4

It does appear that the accessibility is being impacted by the loader somehow. I have found a suitable alternative by accessing the variable from outside the component. Thanks for explaining that Vue and Angular are JavaScript. :grin: