how to do XML parsing in android? - android

i am new to android and xml. so, i would like to know what is xml parsing and how and where we can use it in android application development.
I would also like to know the syntax to be used for this purpose.
thanks

For an introduction to XML, why not start by reading the Wikipedia entry? Basically it is a standardized way to put in form some textual data ; and it is widely used for many, various applications, online or offline.
"Parsing" means processing the XML data to extract values that can be used in your program's code.
When developing for Android, some XML files are used to store application data (e.g. UI layout, Android manifest,...) The parsing of these files is done automatically at build time by the Android Developer Tools, so you do not need to program it. For example, in this part of the Hello World tutorial, you can learn how to use the XML layout files to compose your User Interface.
If you do need an XML parser, as user Rahul recommended in this question, this great page presents three ways to parse XML on Android and shows example code.

The Android platform is an open source mobile development platform. It gives you access to all aspects of the mobile device that it runs on, from low level graphics, to hardware like the camera on a phone. With so many things possible using Android, you might wonder why you need to bother with XML. It is not that working with XML is so interesting; it is working with the things that it enables. XML is commonly used as a data format on the Internet. If you want to access data from the Internet, chances are that the data will be in the form of XML. If you want to send data to a Web service, you might also need to send XML. In short, if your Android application will leverage the Internet, then you will probably need to work with XML. Luckily, you have a lot of options available for working with XML on Android.
XML parsers
Frequently used acronyms
API: Application programming interface
RSS: Really Simple Syndication
SDK: Software Developers Kit
UI: User interface
URL: Universal Resource Locator
XML: Extensible Markup Language
One of the greatest strengths of the Android platform is that it leverages the Java programming language. The Android SDK does not quite offer everything available to your standard Java Runtime Environment (JRE,) but it supports a very significant fraction of it. The Java platform has supported many different ways to work with XML for quite some time, and most of Java's XML-related APIs are fully supported on Android. For example, Java's Simple API for XML (SAX) and the Document Object Model (DOM) are both available on Android. Both of these APIs have been part of Java technology for many years. The newer Streaming API for XML (StAX) is not available in Android. However, Android provides a functionally equivalent library. Finally, the Java XML Binding API is also not available in Android. This API could surely be implemented in Android. However, it tends to be a heavyweight API, with many instances of many different classes often needed to represent an XML document. Thus, it is less than ideal for a constrained environment such as the handheld devices that Android is designed to run on. In the following sections, you will take a simple source of XML available on the Internet, and see how to parse it within an Android application using the various APIs mentioned above. First, look at the essential parts of the simple application that will use XML from the Internet.

Xml parser is done through SAX, DOM and pull parser

Related

Using PyQt5 to interact with HTML content in Android app

As the title says, I need a way to use PyQt5 to interact with HTML/JS web elements from within an app that should be deployed (also) to Android. I started looking at QWebEngine and QWebChannel and the result in terms of interaction is exactly what I need. Sadly, I realized that QWebEngine is not supported by Qt for Android, and I am kind of stuck right now.
I've been reading that is somehow possible to use the deprecated QWebKit instead of QWebEngine, but:
One would need to compile PyQt with QWebKit (and I don't know how to do that)
I have no idea how to replace the functionality of QWebChannel (is this required or should I be able to use it along with QWebKit?)
I don't know if it worths the effort, given that QWebEngine is newer and possibly it will be supported in the (hopefully near?) future.
Last, I should add I don't know anything about QML and its interactions through PyQt, if this is important in this scenario.
Can anybody suggest if using QWebKit now is the way to go, or an alternative path to follow? Should I consider giving up using PyQt for my purpose at present?
-- EDIT1 --
I think I found something interesting regarding using QtWebView.
Qt WebView provides a way to display web content in a QML application
without necessarily including a full web browser stack by using native
APIs where it makes sense.
This is useful on mobile platforms such as Android, iOS, and WinRT;
especially on iOS, where policy dictates that all web content is
displayed using the operating system's web view.
Unfortunately, this imples understanding a bit of QML and using QQuickWidget to embed the QML webview inside a widget (as suggested here).
Does anybody have experience in using QtWebView with PyQt5 and can provide some suggestions? Would this be a reasonable path?

Is PascalScript compatible with Delphi XE5 to create Android/iOS/Windows applications?

I want to create an application that will draw simple forms based on JSON data. I need to have a script to put intelligence on that.
Is Pascal Script from RemObjects a solution for that?
Is is compatible to generate application with the same source code for Android, iOS and Windows?
EDIT: Extending to better understand the need: I have a delphi program that draws a form (pretty much like a dfm file, as a descriptor) and fill it with data from a database. However there is a need for inteligence to validate the data entered. Since the form and data and the validation rules are done by the user there is no way to be a "regular" pascal source code. For that an script language would be perfect, and since I need the same form and same script works in each platform that I could delploy my application it would be also perfect.
This script language should be able to work with exposed objects and deal with database operations (via exposed objects should work also), it is not only a simple IF statement, but there is not need of classes definition. Basically the same concept of what is possible to be done inside a delphi event when attributed by the IDE on OnClick for a TButton for example. It can validate fields, make a calculation of totals, save to a database.
EDIT: I have found that http://www.paxcompiler.com/ PaxCompiler is capable of implement scripting on all target platforms of XE5. I have contacted all the other scripting around this is the only one up to now.
If you want to draw shapes based on JSON data, then just interpret the data using Delphi code and have Delphi to draw the shapes or create the controls.
However I think it is a better idea to create some dummy code and ask RemObject support.
See: http://www.remobjects.com/support/
You can write them an email with some source/pseudo code of what you're trying to do and see what they say.

How to create a multi-platform localization solution?

I am .NET developer and currently working with WPF and ASP.NET MVC 4. The next project I should start will be a web application with good chance to later create clients for desktop/mobile/tablets. In other words, this application could be used from the web browser but also from native applications on Android, iOS, WinPhone8 and Windows Desktop (WPF). I have very limited experience with iOS development and none with Android dev.
One of the features I plan to have in this product is ability for users to select a language on which they want to use GUI, be it in web browser or any other client. Thus I need to create localization solution that would work with all platforms I plan to support. Since I am starting this project with first creating the web app in ASP.NET MVC I am not interested in using Microsoft's default support for localization via resources files (.resx) since that wouldn't be portable.
What are different options out there for creating multi-language support in apps deployed for various platforms? The first idea is to use XML files but I am also interested in exploring other possible solutions that might already exist out there. Any ideas on how to approach this problem are welcome.
First of all I'm not sure if your question should be addressed to the Android and iOs developers (using the iOs and Android tags) because if the client loads content provided by the server then the most common way to do this localization (i encountered very often) is to provide different URL's for different languages, probably with a parameter in the url, something like wwww.yourserver.com/en_us/otherstuffhere where en_us should be the country code and in this way the client can change the URL that will use for the following requests.
Of course it's rely hard to localize all the app using a server content, especially UI components such as button titles, placeholders etc. for these there are proper ways to localize them using iOS and Android OS features for localization.
P.S I have no idea how Windows phone OS works.
As far as I know, there is nothing really out there that would do what you want.
Most systems work well with JSON.
What you could do, is use any of the .resx to JSON solutions that are out there and just store all your localization strings in resx and then automatically convert them to JSON for other platforms.
Forget about one solution, just use whatever format the plattform offers and use a tool like Trados or Transifex to manually convert the different formats.
I'd recommend to use whatever format given platform has native, otherwise you will cause you lot of extra troubles.
You can then either use some tools to convert and merge these formats (translate-toolkit is great in this) or use some translation platform which will allow you to translate all of them in one interface. Transifex (service), Crowdin (service) or Weblate (service or instalable) should be able to do this.
Weblate can help you also with keeping them in sync, I don't think others have such feature (I'm author of Weblate).

Android and no XML

I'm a beginner and building android apps and I was wondering, do i have to use XML to build a successful android app?
how does it affect how to user uses the application?
Without XML, is it less secure?, especially if the application requires log in credentials?
I was not able to find any examples online referring to other methods of building an android app than with XML.
Sorry if my question feels stupid, but i would really appreciate a response. Thank you.
do i have to use XML to build a successful android app?
No. You can make your entire layout in Java, and have it look exactly the same (apart from a couple of themeing options that can only be applied through XML).
However, you must have some XML files, like AndroidManifest.xml, and your widget XMLs if you have a homescreen widget.
how does it affect how to user uses the application?
In 99% of the cases, they won't notice.
Without XML, is it less secure?
This question makes no sense.
especially if the application requires log in credentials?
Again, this makes no sense.
How you build your UI is unrelated to security.
Do i have to use XML to build a successful android app?
Well, you need XML to create a native Android app at all since you need an Android Manifest, which happens to be a XML file. It's also a good practice to use String resources and not to use hardcoded strings throughout the app. But I'm sure you are asking weather you need to build your layout in XML, or not right?
In this case you don't have to use XML, but I would recommend you to since building your entire layout dynamically can be a lot more difficult than building it in XML(my personal opinion). But it's possible of course.
how does it affect how to user uses the application?
If you do everything right then a XML build layout can be the same as a dynamically-build one. (There are even a few API advantages building the layout with java than with XML)
Without XML, is it less secure?
No.

Building Peer to Peer photo sharing on Android

I am planning to do a project on Peer to Peer photo sharing on Android. My professor wants me to do that using some language other than Java or C/C++. Is any of Erlang, Haskell, Ocaml,
Scala, Go helpful to build an android app with following functionality?
Ability to design a GUI for android to view the pictures to be shared
Support for socket communications to transfer the pictures?
Since Android relies heavily on Java, Scala would be a good choice here. Scala makes interoperating with Java code easy and runs on the JVM. On top of this, it is a nice functional language with an interesting type system, so it will be a good learning experience. (So will your other languages, but Scala is probably easier to use on Android.)
Check out Scala Programming for Android, which describes how you can make Android applications in Scala.
You can compile and execute Go programs on Android (or ARM in general), but you can't actually use the Android libraries. So, writing services or GUI applications for Android in Go is currently not that easy. I am not sure about the other languages, but I think Erlang, Haskell, Ocaml, etc. have similar problems (if they even provide an ARM compiler).
Therefore it's probably best to focus on a JVM based language. Most of the examples and other applications are written in Java, but Scala is also able to access all those APIs. So, I would either use Java or Scala.
There's also this JVM-based functional, dynamic, lisp-like language Clojure, which some people seem to like a lot. It should be possible to use it to write Android Apps.
Well, in my view, it depends on what you want to really use the language for as regards your project. Photo Sharing: are you planning on using Web based tools for the client, i.e. JavaScript, HTML5, CSS3, JQuery Mobile (http://jquerymobile.com/), sencha Touch (http://www.sencha.com/products/touch), Phone Gap (http://phonegap.com/),Titanium Appcelerator OR you want to use native stuff like Java, J2ME, e.t.c. Then if its web based (which would make things easier in my view), the language you are referring to in this case would be on the Server side. So in my view if you just need the language to web-serve photos and stuff, then it would not matter which one you use: really depends on your liking. I am pretty sure that Erlang, Scala, Java and the others all have capability for developing great web services. However, the conditions you put as below:
1) Ability to design a GUI for android to view the pictures to be shared 2) Support for socket communications to transfer the pictures?
Suggest that you were referring to a Front-End technology to use. You cannot use Erlang to create GUIs on Android, if i am right, you may not also be able to use Haskell and OcamL as well because these technologies cannot run on the device. For GUIs on Android, you can only use Java, OR you can use Widget Technologies like Opera Widgets OR you use Web based stuff like i mentioned above. However, you should know that using JavaScript Libraries, HTML5, CSS3, e.t.c. is the quickest and more manageable way of developing Apps on any Device. I even wonder why you are talking of Socket Communications !! Am i getting you right ? you want to develop a Photo Sharing App which transfers Photos over raw Socket Communications ? Well, i am NOT sure how many apps out there for Android are doing raw Socket stuff, but i am pretty sure that many (http://androidapplications.com/) are using HTTP Protocol, as in Web Services. Consider looking into web services than raw Sockets. I am pretty sure that even apps developed using native Java, uses HTTP (Web Services like SOAP) to communicate with a remote Server, be it weather apps, location-based stuff e.t.c. Otherwise i guess you should concentrate on Java, for now.

Categories

Resources