how can i convert a javascript variable to a java string variable - javascript

I'm trying to get a javascript variable from my webview and convert it to a String variable in Java. But i'm new to javascript and can't figure out how i can do this.
Can anyone help me?

How about using the Android Java/JavaScript bridge to send data between the two layers. The integration technique is part of the core Android framework.
PhoneGap is also great but is overkill if you just want to stick to Android
Here is a tutorial on how this stuff works: http://code.google.com/p/openmobster/wiki/JavascriptBridge
Full Disclosure: I am the Chief Engineer of OpenMobster and I wrote this tutorial

There is no easy way to just pull a variable from client side javascript into application level Java. Hopefully someone can come along and give a good original answer. However, the PhoneGap library has an easy way to do this. PhoneGap can tie javascript events to native application events which is extremely useful. If you really want to do this I would recommend at least checking out PhoneGap.

Related

Creating web application for first time

I am tasked with creating a web application using HTML 5, CSS3 and JavaScript.( For a study assignment) and I have decided I will be making a web app to record your workouts in regards to weight lifting(As well as thing such as graphs and a counter for days without skipping a workout etc..). But there are a few requirements I have to meet and do not fully understand and would appreciate if anyone could help me with any of these enquires.
I need to use in-built cloud storage to ensuring persistence of data through in-built cloud storage. But as I try to create my project to utilize in built cloud storage, I am informed I do not have any subscriptions is there a free alternative to do this, or am I required to obtain a subscription ?.
I have also chosen to use ASP.NET MVC template to create my desired application, and was wondering if you consider this the correct choice for the app I wish to create? .
I am also required to make use of a library/ libraries external to the application and could use some clarification of if this mean using something such as JQuery etc. or I am just not understanding the requirement correctly. ?.
Sorry for such a long winded post. I look forward and pre thank you for and points you can help clear up for me in advance as well as for any addition tip you think a learner could use in the development if there first web app.
If you are a student, then you can apply for a dreamspark subscription for Azure.
I'm a beginner just like you, and I've used ASP.NET MVC to build my first app.I don't think the framework is an important part in project which is for a study assignment. Just use the one that you like most.
There are some packages that I used in my app:
Newtonsoft.Json
JQuery
NInject
log4net
EntityFramework

Is it possible to use javascript instead of java in such conditions?

I made up desktop application using java few years ago. It is no problem to use until now, but these day I think it's better way to run web application than desktop, for some reasons. anyway, I use some objects in java desktop application, for example...
BufferedReader, DataOutputStream, InputStreamReader, OutputStreamWriter,
PrintWriter, HttpUrlConnection ....
Do javascript have such objects supporting similar fucntions...? I'm afraid to they don't have it. I'm just newbie on this, It is just a hobby. so I don't know much about it. but I heard these day's hottest language is javascript, so I just want to jump to javascript...so please help me if you know about something. thanks.
Although the default JavaScript language doesn't allow reading and writing to files the program node.js is designed to act as a server side JavaScript and does allow reading and writing of files along with a broad npm library to add different functionalities.
More information on the nodejs web site

Database access from UWP app in HTML5/JS

What is the best way to use a database (be it Redis, SQLite, WebSQL or just about anything actually) from a UWP app being developed in HTML5/Javascript? For a C# or VB.NET app I guess it would be quite easy, since you can just use stuff like this. But how would I do that for a JS-based app?
I guess one option would be to do a wrapper C# project and use that as a data layer (since I believe my JS/HTML project can invoke methods in my other projects in the solution). Is that the best/easiest way or are there any other really good options that I'm missing somehow? It feels a bit clumsy, since I would prefer a solution with 100% Javascript in this case.
You could use IndexedDB in UWP javascript apps.
You can easily find samples online (here for example) and relevant MSDN documentation is here.

Can I write iOS (Cocoa) apps in JavaScript?

PhoneGap offers a nice solution for writing cross-platform apps with HTML5 and JavaScript.
But I would like to use Interface Builder for the UI, and just write all the controller code in Javascript instead of Objective-C (with of course the option to mix and match and especially call into any Objective-C libraries that I may need).
Is there a framework for this? Something akin to what CamelBones does for Perl.
The reason for wanting to do this is that the non-UI code can ideally be written in JavaScript to be reused for the web version, an possible future Android PhoneGap version, and the server-side (node.js).
You could try using Appcelerator's Titanium product. It lets you write native iPhone apps in HTML+Javascript.
Check it out here. I haven't used it, but it seems like what you want.
The other possibility is to use iOS Javascript Bridge to write an app in Javascript.
https://github.com/coolbloke1324/iOS-JavaScript-Bridge
You can try JSCocoa. It lets you write Cocoa apps in JavaScript, like a bridge.
It works on a Mac and iPhone. It also works with Interface Builder while you develop.
Here's an article that mentions a few alternatives to using Objective-C
Just stumbled upon this (old) question but wanted to contribute by mentioning NibleKit (http://www.nimblekit.com/index.php) that let's you build native iOS apps with just HTML & Javascript.

Introductory JavaScript programming task for an expert developer

What would be a good mini-project to get intimate with JavaScript, as an advanced 'introduction' to the language? I want to actually code an application in JS, not hook up bits of it to enhance a web application.
A lot of stuff you could learn by doing an RSS reader on a page. Google shows what can be done. The whole lection concentrates on javascript, network access, security restrictions and medium data mangeling.
If you have the ability to do any sort of backend programming than AJAX is really neat to do. You can get a lot of good effects with less efforts. A good thing to build on up.
I would argue that if you're really an advanced programmer then the exercises above would not really give you any insight into the language as they are just variations on things you probably have already done. Javascript's strongest suit is it's LISP style ability to grow. Write something AI(ish) that creates new functions. Most people don't utilize the language in this way, but, its ability to augment its own classes on the fly is, I would argue, it's most unusual and most powerful feature.
Although not a project, watch the Douglas Crockford videos at YUI theater.
The biggest web based Javascript projects are going to deal with the DOM. Do some nifty stuff with JQuery. Make a table with rows that highlight when you hover. Make them update themselves through AJAX and JSON when you click on them.
If you're really looking for something magical and usefull write a scrollable table with fixed headers and footers for IE8.
If you want to stay away from the WEB use the JDK 1.6 and run Javascript code in that. You could do TONS with that.
Whenever I'm trying to get familiar with a language, I will work on Project Euler problems with it.
I would implement a simple game like sokoban first.
The second application would be an AJAX-based multiuser chat application, first fetching other people's responses by polling, later with AJAX push.
Interesting question.
Really you could do any sort of application. In order to make sure you're using the latest and greatest stuff, I'd try making a simple CRUD style application using DHTML and AJAX. Perhaps a contacts list or calendar. If you're feeling really energetic, you could write the back-end in JavaScript as well.
Unless you want to get really friendly with the DOM and browser compatibility, I'd learn Javascript through the mask of one of the nice frameworks like Jquery or Prototype.
The Holy Grail - a WYSIWYG editor. They wouldn't need to complete it, but just seeing their plan of attack would be interesting. Plays right into patterns and OO.
I suggest you create a Google Gadget. You can create one for free and perhaps make something useful out of it. If you don't have a Google account, sign up for one. Then add the Google Gadget Editor to begin writing your code.
With the gadget, you'll be able to mess with JavaScript, JSON, CSS, etc. Furthermore, you'll be able to store the file on Google's server so you can work on it from any computer.
I created a simple RSS reader and wrote JavaScript to get the feed (using Google's API) then dealing with that JavaScript object because it came back as JSON. I then developed some JavaScript to hide/show div tags.
It was a good starter project for me to learn JavaScript.
Get JavaScript the Good Parts by Douglas Crockford. Also check out his web site: http://www.crockford.com
Key reason: just because JavaScript looks like C/C++/Java/C# doesn't mean it actually is like them. Things are significantly different. I suggest reading his book to get a grasp of those differences.
Otherwise, I would look at the JQuery web site. JavaScript is cool and all, but a good framework will save you from a lot of the pitfalls and make you much more productive faster.
try making an advanced AJAX application like for example try to recreate the google calander.
How about a firefox plugin to monitor StackOverflow? It could use RSS to monitor feeds and let you know when new questions are asked with your tags.
It could also be grown as your js skills progress.
Write yet another javascript framework, but focused specially in something, ie game programming.

Categories