René's URL Explorer Experiment


Title: [Proposal] Use custom classes required at compile time (e.g. Activity, Application, etc.) · Issue #283 · NativeScript/android · GitHub

Open Graph Title: [Proposal] Use custom classes required at compile time (e.g. Activity, Application, etc.) · Issue #283 · NativeScript/android

X Title: [Proposal] Use custom classes required at compile time (e.g. Activity, Application, etc.) · Issue #283 · NativeScript/android

Description: Overview In Android development it is a standard practice to use inheritance to create custom activities, applications and other components. Currently NativeScript runtime for Android ({N}) has limited support for this scenario. This pro...

Open Graph Description: Overview In Android development it is a standard practice to use inheritance to create custom activities, applications and other components. Currently NativeScript runtime for Android ({N}) has lim...

X Description: Overview In Android development it is a standard practice to use inheritance to create custom activities, applications and other components. Currently NativeScript runtime for Android ({N}) has lim...

Opengraph URL: https://github.com/NativeScript/android/issues/283

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Proposal] Use custom classes required at compile time (e.g. Activity, Application, etc.)","articleBody":"## Overview\n\nIn Android development it is a standard practice to use inheritance to create custom activities, applications and other components. Currently NativeScript runtime for Android ({N}) has limited support for this scenario. This proposal aims to provide a solution for creating custom activities, applications and other components.\n\n> Note: for the sake of this proposal I use the common scenario to extend an activity class.\n## Current State\n\n{N} provides built-in `NativeScriptApplication` and `NativeScriptActivity` classes. While these classes helped the adoption of {N} they also provide limitations. Currently it is not possible to inherit from a third party activity or other types which are used in `AndroidManifest.xml` file.\n## Technical Details\n\nHere is how a Java class is extended in {N}\n\n``` JavaScript\n// app/myactivity.js\nvar MyActivity = android.app.Activity.extend({\n   onCreate: function(bundle) {\n      // implementation\n   }\n});\n```\n\nHowever `MyActivity` class is generated at runtime by {N} bridge. This mean you cannot use `MyActivity` in `AndroidManifest.xml` the way we currently use `NativeScriptActivity` for example.\n\n``` XML\n\u003c!-- AndroidManifest.xml -->\n\u003cactivity\n    android:name=\"com.tns.NativeScriptActivity\"\n    android:label=\"TestApp\">\n    \u003cintent-filter>\n        \u003caction android:name=\"android.intent.action.MAIN\" />\n        \u003ccategory android:name=\"android.intent.category.LAUNCHER\" />\n    \u003c/intent-filter>\n\u003c/activity>\n```\n## Proposal\n\nThe current `extend` implementation can accept two parameters as well. We can rewrite the previous example as follows\n\n``` JavaScript\n// app/myactivity.js\nvar MyActivity = android.app.Activity.extend(\"MyActivity\", {\n   onCreate: function(bundle) {\n      // implementation\n   }\n});\n```\n\nWe can leverage the latter syntax of `extend` function and pass the fully qualified type name of the new class as follows\n\n``` JavaScript\n// app/myactivity.js\nvar MyActivity = android.app.Activity.extend(\"com.example.MyActivity\", {\n   onCreate: function(bundle) {\n      // implementation\n   }\n});\n```\n\nDuring build time we can parse the JavaScript and generate Java file `com/example/MyActivity.java`. This proposal will not make the existing code ambiguous because currently there is a validation rule that says the class name cannot contain `.` symbol. The generated `MyActivity.java` file will look as follows\n\n``` Java\n// com/example/MyActivity.java\npackage com.example;\n\n@com.tns.JavaScriptImplementation(javaScriptFile = \"app/myactivity.js\")\npublic class MyActivity extends android.app.Activity {\n   public MyActivity() {\n      com.tns.Platform.initInstance(this);\n   }\n   public void onCreate(android.os.Bundle param_0) {\n      Object[] args = new Object[1];\n      args[0] = param_0;\n      com.tns.Platform.callJSMethod(this, \"onCreate\", void.class, args);\n   }\n}\n```\n\nThis is how the currently **runtime** generated types look like. We can provide a tool that generates equivalent types at **build time**. The only difference is the use of `com.tns.JavaScriptImplementation` annotation. The need a way to find the JavaScript implementation for `MyActivity` when an instance is created. Using annotation is just one possible approach. I find it clear and, more importantly, I find it aligned with the following proposition how to extend Java class in TypeScript.\n\n``` TypeScript\n// myactivity.ts\n@JavaProxy(\"com.tns.MyActivity\")\nclass MyActivity extends android.app.Activity {\n   onCreate(bundle: android.os.Bundle)  {\n      // implementation\n   }\n}\n```\n\nUsing ES6/TypeScript decorators is a simple way to indicate that we have to generate Java class at build time. The main benefit of using decorators is that the change is less obtrusive than other alternatives.\n## Impact\n\nThis proposal will require [{N} modules](https://github.com/NativeScript/NativeScript) to change the way an application is initialized and activities are created. I expect that this would be small-to-medium change. The immediate benefits are better encapsulation and control. Also, it may require {N} modules to come with prebuilt `Activity` and `Application` classes. Another approach would be adding these classes to the project template.\n## Summary\n\nThis proposal has some other benefits as well. Removing `NativeScriptActivity` and `NativeScriptApplication` from {N} will allows us to support [lower Android API levels](https://github.com/NativeScript/android-runtime/issues/198). Currently we have to compile against API level 17 and there is no technical justification for that. Also it will allow embedding {N} in other applications much easier. One primary scenario is [NativeScript companion app](https://play.google.com/store/apps/details?id=com.telerik.NativeScript&hl=en).\n\nFinally, you can find a prototype [here](https://github.com/NativeScript/android-runtime/tree/slavchev/new-project-template2)\n","author":{"url":"https://github.com/slavchev","@type":"Person","name":"slavchev"},"datePublished":"2015-11-27T16:31:58Z","url":"https://github.com/NativeScript/android/issues/283"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:64013b14-2d6d-cdf2-b79c-35506b5a9a59
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8284:2D96F1:1B638C9:2426C65:6B0150AB
html-safe-nonce3962e548b91dc89c6382a83304ec6c398766e4a8f41fdebf851830669c32eeed
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Mjg0OjJEOTZGMToxQjYzOEM5OjI0MjZDNjU6NkIwMTUwQUIiLCJ2aXNpdG9yX2lkIjoiMjAyMTEwNjk2ODcwOTY0ODU1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac5f2c336afd9ae6a223d4cd8d5e30b95fb8bfdc8f7efa7b694ef7c917105b018f
hovercard-subject-tagissue:119221398
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/NativeScript/android/283/issue_layout
twitter:imagehttps://opengraph.githubassets.com/553a950b51ed216ef725470df4161210a69ae2fd421fef60301d0fde9b3e8230/NativeScript/android/issues/283
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/553a950b51ed216ef725470df4161210a69ae2fd421fef60301d0fde9b3e8230/NativeScript/android/issues/283
og:image:altOverview In Android development it is a standard practice to use inheritance to create custom activities, applications and other components. Currently NativeScript runtime for Android ({N}) has lim...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameslavchev
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-preview
go-importgithub.com/NativeScript/android git https://github.com/NativeScript/android.git
octolytics-dimension-user_id7392261
octolytics-dimension-user_loginNativeScript
octolytics-dimension-repository_id29137950
octolytics-dimension-repository_nwoNativeScript/android
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id29137950
octolytics-dimension-repository_network_root_nwoNativeScript/android
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/NativeScript/android/issues/283#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fissues%2F283
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FNativeScript%2Fandroid%2Fissues%2F283
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=NativeScript%2Fandroid
Reloadhttps://github.com/NativeScript/android/issues/283
Reloadhttps://github.com/NativeScript/android/issues/283
Reloadhttps://github.com/NativeScript/android/issues/283
NativeScripthttps://github.com/NativeScript
androidhttps://github.com/NativeScript/android
Codehttps://github.com/NativeScript/android
Issues106 (106)https://github.com/NativeScript/android/issues
Pull requests25 (25)https://github.com/NativeScript/android/pulls
Actionshttps://github.com/NativeScript/android/actions
Projectshttps://github.com/NativeScript/android/projects
Wikihttps://github.com/NativeScript/android/wiki
Security and qualityhttps://github.com/NativeScript/android/security
Insightshttps://github.com/NativeScript/android/insights
https://github.com/NativeScript/android
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/android/issues/283
New issuehttps://github.com/login?return_to=https://github.com/NativeScript/android/issues/283
[Proposal] Use custom classes required at compile time (e.g. Activity, Application, etc.)https://github.com/NativeScript/android/issues/283#top
donehttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22done%22
featurehttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22feature%22
severity: highhttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22severity%3A%20high%22
1.7.0https://github.com/NativeScript/android/milestone/12
https://github.com/slavchev
slavchevhttps://github.com/slavchev
on Nov 27, 2015https://github.com/NativeScript/android/issues/283#issue-119221398
{N} moduleshttps://github.com/NativeScript/NativeScript
lower Android API levelshttps://github.com/NativeScript/android-runtime/issues/198
NativeScript companion apphttps://play.google.com/store/apps/details?id=com.telerik.NativeScript&hl=en
herehttps://github.com/NativeScript/android-runtime/tree/slavchev/new-project-template2
Nexthttps://github.com/NativeScript/android/issues/283?timeline_page=1
slavchevhttps://github.com/slavchev
featurehttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22feature%22
on Nov 27, 2015https://github.com/NativeScript/android/issues/283#event-476524078
https://github.com/gordonpro
gordonprohttps://github.com/gordonpro
on Dec 1, 2015https://github.com/NativeScript/android/issues/283#issuecomment-160963821
https://github.com/gordonpro
gordonprohttps://github.com/gordonpro
on Dec 1, 2015https://github.com/NativeScript/android/issues/283#issuecomment-160963868
https://github.com/slavchev
slavchevhttps://github.com/slavchev
on Dec 1, 2015https://github.com/NativeScript/android/issues/283#issuecomment-160968999
@gordonprohttps://github.com/gordonpro
Telerik AppBuilderhttp://www.telerik.com/appbuilder
https://github.com/sitefinitysteve
sitefinitystevehttps://github.com/sitefinitysteve
on Dec 1, 2015https://github.com/NativeScript/android/issues/283#issuecomment-160975888
https://github.com/jlooper
jlooperhttps://github.com/jlooper
on Dec 11, 2015https://github.com/NativeScript/android/issues/283#issuecomment-163974825
https://github.com/gordonpro
gordonprohttps://github.com/gordonpro
on Dec 11, 2015https://github.com/NativeScript/android/issues/283#issuecomment-163976629
@slavchevhttps://github.com/slavchev
https://github.com/slavchev
slavchevhttps://github.com/slavchev
on Dec 12, 2015https://github.com/NativeScript/android/issues/283#issuecomment-164126894
@gordonprohttps://github.com/gordonpro
@teobugslayerhttps://github.com/teobugslayer
@hshristovhttps://github.com/hshristov
valentinstoychevhttps://github.com/valentinstoychev
on Dec 12, 2015https://github.com/NativeScript/android/issues/283#event-490058594
atanasovghttps://github.com/atanasovg
severity: highhttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22severity%3A%20high%22
on Jan 5, 2016https://github.com/NativeScript/android/issues/283#event-505857641
https://github.com/katturajam
katturajamhttps://github.com/katturajam
on Feb 8, 2016https://github.com/NativeScript/android/issues/283#issuecomment-181408301
slavchevhttps://github.com/slavchev
1.6.0https://github.com/NativeScript/android/milestone/11
on Feb 8, 2016https://github.com/NativeScript/android/issues/283#event-543124850
https://github.com/slavchev
slavchevhttps://github.com/slavchev
on Feb 8, 2016https://github.com/NativeScript/android/issues/283#issuecomment-181442925
@katturajamhttps://github.com/katturajam
https://github.com/NativeScript/android-runtime/tree/slavchev/new-project-template2/test-app/src/com/tnshttps://github.com/NativeScript/android-runtime/tree/slavchev/new-project-template2/test-app/src/com/tns
https://github.com/slavchev
slavchevhttps://github.com/slavchev
on Feb 8, 2016https://github.com/NativeScript/android/issues/283#issuecomment-181443826
https://github.com/NathanaelA
NathanaelAhttps://github.com/NathanaelA
on Feb 8, 2016https://github.com/NativeScript/android/issues/283#issuecomment-181475145
Plamen5kovhttps://github.com/Plamen5kov
on Mar 3, 2016https://github.com/NativeScript/android/issues/283#event-576626739
Plamen5kovhttps://github.com/Plamen5kov
ready for testhttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22ready%20for%20test%22
on Mar 9, 2016https://github.com/NativeScript/android/issues/283#event-583233452
slavchevhttps://github.com/slavchev
donehttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22done%22
ready for testhttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22ready%20for%20test%22
on Mar 16, 2016https://github.com/NativeScript/android/issues/283#event-591782876
slavchevhttps://github.com/slavchev
completedhttps://github.com/NativeScript/android/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Mar 16, 2016https://github.com/NativeScript/android/issues/283#event-591782981
https://github.com/sitefinitysteve
sitefinitystevehttps://github.com/sitefinitysteve
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199395246
https://github.com/NathanaelA
NathanaelAhttps://github.com/NathanaelA
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199406142
https://github.com/sitefinitysteve
sitefinitystevehttps://github.com/sitefinitysteve
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199409773
@NathanaelAhttps://github.com/NathanaelA
https://github.com/sitefinitysteve/nativescript-auth0/tree/master/plugin/platforms/androidhttps://github.com/sitefinitysteve/nativescript-auth0/tree/master/plugin/platforms/android
https://github.com/NathanaelA
NathanaelAhttps://github.com/NathanaelA
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199422971
https://github.com/sitefinitysteve
sitefinitystevehttps://github.com/sitefinitysteve
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199425061
@NathanaelAhttps://github.com/NathanaelA
https://github.com/slavchev
slavchevhttps://github.com/slavchev
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199456791
@NathanaelAhttps://github.com/NathanaelA
@sitefinitystevehttps://github.com/sitefinitysteve
https://github.com/sitefinitysteve
sitefinitystevehttps://github.com/sitefinitysteve
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199457913
@slavchevhttps://github.com/slavchev
https://github.com/NathanaelA
NathanaelAhttps://github.com/NathanaelA
on Mar 21, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199484330
https://github.com/Plamen5kov
Plamen5kovhttps://github.com/Plamen5kov
on Mar 22, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199678369
@NathanaelAhttps://github.com/NathanaelA
https://github.com/NathanaelA
NathanaelAhttps://github.com/NathanaelA
on Mar 22, 2016https://github.com/NativeScript/android/issues/283#issuecomment-199796679
Sign up for freehttps://github.com/signup?return_to=https://github.com/NativeScript/android/issues/283
Sign in to commenthttps://github.com/login?return_to=https://github.com/NativeScript/android/issues/283
donehttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22done%22
featurehttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22feature%22
severity: highhttps://github.com/NativeScript/android/issues?q=state%3Aopen%20label%3A%22severity%3A%20high%22
1.7.0https://github.com/NativeScript/android/milestone/12
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.