I like to inject js code into html when the application is done loading through Java. Actually, I have some code which I don't want anyone to see when they extract the application apk, and when that particular js in is embedded in Java code it would be a little difficult to extract. I know the complete java code for the apk can be decompiled, but this be make things little difficult.
Can anyone help in this?
I am using PhoneGap/Cordova 2.1.0 for Android.
Thanks
some solutions:
write plugin, call you code within a cordova.ready callback
extend the droidgap and call super.loadUrl("javascript:window.alert()");
I would suggest the first one.
Related
I'm aware of all the other questions about this topic, but I haven't found a good solution for my problem. Currently I am trying to use Java code in my C# project. I've already tried to convert the JAR files into .DLL files with IKVM, but this didn't work for me because the JAR files are to complicated to translate into C# because not every component, which were used in Java, can be found in C#. The normal call of the JAR file doesn't work for me either because I need to work with the class instances of the declared classes in the Java code.
Back to my question: Does anybody know how I could use Java code in my project? I've heard that it may be possible to implement Java code like it would be native, is that true? Note that I've to work with the class instances of the classes declared in the Java code.
I highly appreciate any kind of help, sheers!
Edit:
My work around would be that I include batch files, which are calling the JAR files. I will include these batch files into my C# Project and work with the batch files. This may be a even better approach for me because every input and output of the JAR files are done via XML files.
This kind of mixup are not generally a good approach. I think the .Net Framework is very mature and you can find everything you want to do your work.
I would suggest you the following approach :
You can wrap your Java library in a REST API and call it in your C# code. Your REST API can be hosted on an external server or use an embedded server or even a spring boot project.
You can read this post for more details.
I am writing a new service Convert-HTML-TO-PDF. But now I am confused that what way should I prefer.
What ways I have to implement:
Use Head-less browser and capture the HTML page and convert to PDF
Use Java/Node Lib to convert. Which will create HTML relevant component in PDF file and then render?
Now, please help me to understand what will be the best way to implement a service and why!
[update]
And what will be the advantages and disadvantages of each approach
In my view, the best way forward always depends on what you already have experience with and what approach you take. There is no right or wrong here, everyone has to decide that for themselves based on their preferences.
Each approach has advantages and disadvantages. Some of them are:
Headless Browser:
Advantage:
No large Libs necessary, therefore very memory saving
Disadvantage
the desired browser must be installed on the computer/server
rendering may differ for different browsers
Library:
Advantage:
different libraries available
for the popular libs there is a good documentation and code examples
Disadvantage
When upgrading to a newer version, code usually needs to be adapted.
When upgrading to a newer version, the result may look different.
In my projects I use a headless chrome browser. For this I found an easy to use api on Github, which uses the DevTools of Chrome.
It also includes a simple example how to print a page into a PDF.
For my purposes I have customized this example and write the HTML into a temporary file and then navigate to that file.
// Navigate to HTML-File
page.navigate(htmlTempFile.getAbsolutePath());
I can't say if this is the best way, but for me this was the easiest and most understandable way
I have some java class files that I would like to run from javascript. They take in a string and spit out a string. I am trying to figure out the best/easiest way to execute them the class files from javascript so I can get/use its response. So as far as I know now here are my options.
Javascript ajax request to php then maybe exec() the jar
Javascript ajax request to my class files re implemented as servlet
Rewriting the class files as javascript and call it a day
1 is not ideal because I don't avoid using php, if I can. 2 sucks cause I don't want to run Apache Tomcat. 3 sucks naturally.
Long story short, I wrote a beautiful implementation of A* in java and I want to use it in a game I wrote in js without rewriting it. What would you do?
It isn't possible to run Java through Javascript completely independently without using HTML. However, it isn't impossible.
You will first need to convert your Java game (.JRE file) into an applet. To do that, you might take the public static main void and replace it with an Applet initialization (how to use applets). It might seem tedious, but when you actually do it, it won't be that difficult.
Then, using Javascript's HTML Document Object Model (learn more), you can easily do something like this:
document.write('<embed src="foo.class">');
Also, keep in mind that the <applet> tag is NOT supported in HTML5. Like shown above, you can use the <embed> tag or also the <object> tag.
Sincerely, PD.
I found simple code to extract text from PDF files here, and I'm wondering if there is an easy way to add it to my existing app in order to add this functionality?
Yes that is doable since the code is written in C. It will be complex if you are a beginner as you will have to use Android NDK to interface the C code to Java using JNI
I'm developing a web application with SmartGWT and I found an issue with Chrome. To solve the issue I modify part of my /war/projectName/sc/modules/ISC_Core.js. Following is the code I modify:
isc.Browser.isDOM?"
if(event.target.id.indexOf(\"Geoviewer_\") != -1){return true;}
if(returnVal==false)event.preventDefault();else if(returnVal==isc.EH.STOP_BUBBLING)event.stopPropogation();":"")+"return returnVal;"
The second line is the one I add to make the code work under specific circumstances in Chrome.
Now, unfortunately this is not a very 'clean' solution as I have to make the modification after the compilation because the file is generated after it. So my question is how can I find the piece of Java in the GWT code that is generating this Javascript so as to modify it once for ever and have the project compiling right without the necessity of further modifications?
Thanks for your help
The ISC_ Javascript files aren't being generated by GWT. SmartGWT is just a wrapper between GWT and a native Javascript library (SmartClient); it's basically the equivalent of a JNI AWT toolkit interface. If you have a repeatable bug, contact Isomorphic; they're pretty good about addressing demonstrable issues.