-
-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Errors extending NativeScriptActivity on Android #462
Comments
From @chimon2000 on May 24, 2016 17:17 Further DetailsWhat I am actually trying to do is extend the NativeScriptActivity to add an event for user interaction that I can handle on the JS side. I reviewed the blog post about SBG, but could not figure out how to override NativeScriptActivity in
results in no I also attempted the following
which results in just a blank screen being displayed. I'm sure that both of these fail because the generator is static (of course). Just not sure how to get the desired result of overriding/adding to the default activity. |
From @vjoao on May 24, 2016 19:11 Maybe new it?
|
From @chimon2000 on May 24, 2016 20:29 @vjoao I attempted that with just the default Activity I also tried removing the assign and just passing in mainActivity. In both cases It appears that only passing the object directly into the method yields the expected outcome (makes sense because it is static). |
Hi @chimon2000 Firstly, let me acknowledge that current mechanism for extending activities is bit rough and generally requires some understanding how {N} works. While it is functional it is not developer friendly. Think of it as a first step in an iterative process. The good news is that last week I prepared an internal document, which is in review now, and I guess I will publish it as a github issue next week so the discussion continues in public. With that said, let me try to help. You can extend an activity as follows: var MyActivity = android.app.Activity.extend("com.example.MyActivity", {
onCreate: function() {
// body omitted
}
}); During build-time the static binding generator will create new
is not the correct one. In case you want to extend a class that you are going to use in
uses the correct syntax. And indeed as you said you see blank activity. Currently this is the expected behavior because you don't provide any UI. Take a look at how we use this approach in our test app. Basically, we overwrite When it comes to our modules we have slightly different implementation (please ignore TypeScript specifics). This implementation has understandings of the other modules classes like Hopefully I managed to explain what is done until now. What is going next? As I said we are discussing internally the initial draft of a proposal that will allow any developer to extend activities in general, including the ones that comes from our modules implementation. Once we cut the rough corners we will post a issue with the proposal so it can be reviewed in public. I expect it to happen next week. |
+1 |
@emankovski Can you specify what do you need? Perhaps put it on https://nativescript.ideas.aha.io/ideas so people can see and vote for them to be included. |
@vjoao There are many scenarios can come up. One on them, we tried to tackle, is to hook on user interaction to track user activity on high level:
As I said in previous post we have some specific requirement. That is custom timeout. I.e. user has its phone set to lock after 5 minutes but general corporate rules can say just 1 minute. Enterprise mentality is not to trust to user even on his own phone :) So we have to track timeout ourselves... We tried to hook on page level taps but they dont bubble up when controls handle gestures. So we cannot reset timer correctly. The fallback is to go to Native level and try to user Activity methods. We tried to find any way to allow bubbling for NativeScript UI events on a page level, but that could be a feature to consider to implement. |
@slavchev I am glad to hear that you guys are aware of this. Looking forward to reviewing what you come up with! |
Guys, here is the first part of the proposal in question. It is related mostly to the folder structure as such. I will add link to the part related to the changes in our modules once it is ready. |
Closing this issue, please refer to #465 (comment) for further information on what we've enabled for 2.1 |
From @chimon2000 on May 23, 2016 22:30
Versions
tns: 2.0.1
tns-core-modules: 2.0.1
tns-android: 2.0.0
Description
When attempting to extend NativeScriptActivity, I run into several issues:
I took the example from here, and I assume that the information is stale since it refers to bootstrap.js. Unfortunately, I can't find anymore documentation around the feature.
Copied from original issue: NativeScript/NativeScript#2166
The text was updated successfully, but these errors were encountered: