How To Obtain And Parse Data From A Website
Feb 28, 2012
I want to create an app that displays flight information such as: arrival/departure info, canceled flights, etc. I don't know how to query the data from the website in order to display it in the app.
View 4 Replies
Mar 11, 2010
I am porting a Python application to Android and, at some point, this application has to communicate with a Web Service, sending it compressed data. In order to do that it uses the next method:
def stuff(self, data): "Convert into UTF-8 and compress."
return zlib.compress(simplejson.dumps(data))
I am using the next method to try to emulate this behavior in Android:
private String compressString(String stringToCompress) { Log.i(TAG, "Compressing String " + stringToCompress);
byte[] input = stringToCompress.getBytes();
// Create the compressor with highest level of compression Deflater compressor = new Deflater();
//compressor.setLevel(Deflater.BEST_COMPRESSION);
// Give the compressor the data to compress compressor.setInput(input); compressor.finish();
// Create an expandable byte array to hold the compressed data.
// You cannot use an array that's the same size as the orginal because
// there is no guarantee that the compressed data will be smaller than
// the uncompressed data.
ByteArrayOutputStream bos = new ByteArrayOutputStream(input.length);
// Compress the data byte[] buf = new byte[1024];
while (!compressor.finished()) { int count = compressor.deflate(buf);
bos.write(buf, 0, count); } try { bos.close();
} catch (IOException e) { } // Get the compressed data byte[] compressedData = bos.toByteArray();
Log.i(TAG, "Finished to compress string " + stringToCompress);
return new String(compressedData);
}
But the HTTP response from the server is not correct and I guess it is because the result of the compression in Java is not the same as the one in Python. I ran a little test compressing "a" both with zlib.compress and deflate.
Python, zlib.compress() -> x%9CSJT%02%00%01M%00%A6
Android, Deflater.deflate -> H%EF%BF%BDK%04%00%00b%00b
How should I compress the data in Android to obtain the same value of zlib.compress() in Python?
View 2 Replies
View Related
Nov 24, 2010
How can I get crash data (stack traces at least) from my Android application? At least when working on my own device being retrieved by cable, but ideally from any instance of my application running on the wild so that I can improve it and make it more solid.
View 7 Replies
View Related
May 16, 2009
I need to capture an image from camera and display on surfaceview for my project. I am trying to obtain bitmap from data in onPreviewFrame method of previewCallback and display on surface using canvas.
View 5 Replies
View Related
Sep 26, 2010
How to parse xml data.. file is php file and Soap is used in xml..
i am going to use this in a android application.
please provide me proper codes
View 1 Replies
View Related
May 15, 2014
I primarily do hardware and firmware design, but a new product my company is developing has the need for an Android app and since I have the most Android programming experience (which is extremely limited) that leaves the task to me. I need a little guidance figuring out how to do a few things so that I can get this app up and running. I already have a simple GUI to display some stuff, but what I need is a way to handle data.
I am trying to receive a 148 byte stream of data over a serial connection, parse it into a structure and display certain values from that structure. The data is packed in a struct that is sent from a micro controller and due to that it has a very specific layout (i.e. the first 8 bytes mean this, the next 16 bytes are this... ). In C, I can just declare a struct with those values and use the #pragma pack function to eliminate any extra spacing the compiler would otherwise inject for alignment purposes, receive the data and do a memcpy into the struct to write the data. It's not the safest or cleanest way to do it, but it takes very little time and if you do CRC tests to make sure the data received is valid it works like a charm.
Now to the root of the problem: How do I declare structs in Java? Is there a way to pack them tightly like you can using C? Once I've received the binary data, is there a way to parse it into the structure easily? These are the issues we hardware programmers face when dealing with Java...
View 2 Replies
View Related
Oct 29, 2010
i need to parse this response in android using the android json parser but the thing i cant find the answer to anywhere is: how do i parse the data if for example "itineraries" can contain one or sometimes more objects of the type itinerary? if it contains one than it is returned like this but if it contains more it is returned with [] with this example "itinerary" cannot be placed into a JsonArray becouse obviously it is not an array. (not placed in [] right?)
how do i parse this? any examples?
{
"plan":{
"date":"2010-10-20T00:00:00+02:00",
"from":{
"name":"Булевар Партизански Одреди",................
View 1 Replies
View Related
Sep 22, 2011
I have an application that receives data in binary form through bluetooth. I read the data using bluetoothsocket to an byte[]. But i must parse all messages, because they must have an given format and they are in binary.
My solution was to convert byte[] to a string and then split the string and parse all received messages.
An example of the data to parse:
0000000010000001
I should know that the first 8 zeros are the header and 10000001 the real data.
My idea was to create a string that represents -> 0000000010000001 and then split the whole string in one byte and check the value, like:
string1 had 00000000
string2 had 10000001
I know that 8 zeros are the header, therefore string2 has the representation of the data.
View 1 Replies
View Related
Oct 4, 2010
I have a web service, .asmx that when consumed gives a response in the form:
<lData>
<name>...</name>
<posx>..</posx>
<posy>...</posy>
</lData>
I use Ksoap2 to consume the web service in Android, and I see the response as a string anyType {lData=anyType{name=....;posx=....;posy=....;};}
So, I get the right data from my web service, but i don't know how to parse it correctly.
I want to find a way to iterate through the different nodes.
I have tried to use a SAXParser, but can't seem to understand what I should use instead of the url. In the tutotirals I have followed the link to a xml-file on a url, but my url is only part "finished" since i need to consume the web service first. code...
Is this above something I should use, but have another openStream?
View 1 Replies
View Related
Sep 12, 2010
how do you stream certain bits of information from a website. From what I understand webview launches a web page, but what if I want to only stream a paragraph that was published on a site. Example: Yahoo! Fantasy Football. Updates on players and the news feed about them.This is obviously a lot more complicated than my question. I would be interested in a tutorial that could walk me through this. Does this also take programming on the server side to send this out?
View 2 Replies
View Related
Nov 19, 2010
Just wondering what would be the best way to grab the following data and parse it.Here's an example of some the data I want to pull.
<?xml version="1.0" encoding="UTF-8" ?>
<eveapi version="2">
<currentTime>2010-11-19 19:23:44</currentTime>
<result>
<rowset name="characters" key="characterID" columns="name,characterID,corporationName,corporationID">
<row name="jennyhills" characterID="90052591" corporationName="Imperial Academy" corporationID="1000166" />
</rowset>
</result>
<cachedUntil>2010-11-19 20:20:44</cachedUntil>
</eveapi>
I've seen some examples on how to parse XML data but they are all based on if statements and that's a lot of hard coding is there a more genertic way to do this?
View 2 Replies
View Related
Sep 28, 2010
I was wondering what the best approach is on Android to retrieve information from a HTML page hosted on the internet? For example I'd like to be able to get the text from the following page at the start of each day:http://www.met.ie/ forecasts /sea-area.asp I have been downloading and parsing XML files but I have never tried to parse information from a HTML type file before.Is there a native way to parse the information I want?Or do I need a third party library?Or do I need to look into screen scraping?
View 2 Replies
View Related
Nov 14, 2010
I am trying to make an application in which I need to fetch some data from an website. Do we have some sample application which demonstrate how to do this? I do not want to open the website from browser, just want to query through java code..and get the result.
View 2 Replies
View Related
Oct 19, 2010
I am new to Android development and am interested in working out a design of an application. I am however, unfamiliar with the best way to handle what I want to do. I am interested in obtaining information from my band's Joomla website and placing it into an Android application. At the moment I'd like to get News articles posted and potentially other information that I create on the site. I was thinking of doing this by setting up RSS feeds for the website. Would it be better to somehow access the data directly by connecting to the database? I don't know PHP so I can't develop a webservice to access the content. Any ideas?
View 1 Replies
View Related
Nov 12, 2010
I am looking into developing an App that will convert a website into more readable data for an android app. I am at university and have an online notice board which can be viewed on the web but if possible I would like to transfer this into an app on android to make it more easy to read on mobile devices.
What I thinking is that the app would go to the website where the notice board is held and read in the html code to display each notice in a list adapter view. Each notice is within its own div so I assume I could use that to split each notice up into its own button on the list adapter view. Is this possible and if so how I can go about doing this. I have tried google for an answer but I have not yet found a solution to this problem.
View 2 Replies
View Related
Jun 16, 2009
We have a website with free games and we would like to had direct links to the great games from the android Market.
Is there a possibility to get the data automatically from the Android Market to put it on my website?
View 2 Replies
View Related
Mar 9, 2009
Was just wondering if anyone had any code samples about writing and retrieving data from a website? I am currently creating an application which populates its textviews by accessing information from an online source.
View 8 Replies
View Related
Jun 13, 2009
Is there any way to manipulate form-data of a specific website (for example fill in information in a login-field and hit the login- button).
View 3 Replies
View Related
Jan 13, 2010
I'm retreiving data from an Internet service. Is there a way to control which (data) connection the device uses for connecting to a website?(access via wifi or via the cellular network).
View 1 Replies
View Related
May 30, 2010
when i download large data from website, i got this error information:
I/global (20094): Default buffer size used in BufferedInputStream constructor.
It would be better to be explicit if an 8k buffer is required.
D/dalvikvm(20094): GC freed 6153 objects / 3650840 bytes in 335ms
I/dalvikvm-heap(20094): Forcing collection of SoftReferences for 3599051-byte al
location
D/dalvikvm(20094): GC freed 320 objects / 11400 bytes in 144ms
E/dalvikvm-heap(20094): Out of memory on a 3599051-byte allocation.
I/dalvikvm(20094): "Thread-9" prio=5 tid=17 RUNNABLE
I/dalvikvm(20094): | group="main" sCount=0 dsCount=0 s=0 obj=0x439b9480
I/dalvikvm(20094): | sysTid=25762 nice=0 sched=0/0 handle=4065496
View 1 Replies
View Related
Mar 1, 2010
I am new to android programming and have a strong keen interest to learn it. I want to write a program that fetches the data from a website, segregates it and displays it on the screen of the phone. The data could be grocery list from a supermarket or sale items in a mall. Could you please suggest as to how I can go ahead and start this.
View 7 Replies
View Related
Apr 25, 2010
I'm new to Android and web service development currently I'm working in developing Android program that will send longitude and latitude information to asp.net website (to show the location change the website map)the questions are
- how to send this data to the website (the best practice)!
- any suggestions for a suitable framework starting from the android application itself , inserting to database , client/server connection I've read a lot about web services specially REST ..but didn't find tutorials
View 2 Replies
View Related
Jul 11, 2009
Is there a way to obtain a virgin map with the Google Map Api or other API (no city and country names, i want only country borders)?
View 6 Replies
View Related
Aug 23, 2010
I would like to write an app on Android to upload my GPS location to an external website once every 5 minutes. This needs to have as minimal an impact on battery life as possible, but it also needs to work without any user interaction. (Background: I'm competing in an Ironman triathlon which will take me about 14 hours to complete, and want to broadcast my location in near-real-time but without having to worry about fiddling with my phone.) So my initial thought is to write a Service which uses LocationManager.requestLocationUpdates() with a minTime of 5 minutes, but will this actually wake the device up every 5 minutes for my service to do its job?
It sounds like I would also need to use AlarmManager.setInexactRepeating() to make sure my service is awake while it completes its task but how does that play with requestLocationUpdates()? Should I instead set minTime=0 on requestLocationUpdates() but then go back to sleep as soon as the next update is obtained? Any general guidance on how to design this. I'm a competent Java programmer & will be using Google Maps on the server to plot my location, but am pretty new to Android development so I'm basically looking for a high-level plan on how to architect the client app.
View 2 Replies
View Related
Jun 26, 2010
I'm trying to obtain an instance of ServiceState in my Activity. But how am i supposed to do this? There is no static method to obtain an instance or any method on any service that returns an ServiceState instance.
There is the TelephonyManager.listen() call. But i want to get the ServiceState instance when i want, not when android calls my listener because something changed.
The documentation of ServiceState can be found here: http://developer.android.com/reference/android/telephony/ServiceState.html
View 2 Replies
View Related
Jun 9, 2009
I wish to obtain the frequency of an input signal from the mic. Can anyone send me some pointers on how this may be accomplished.
View 2 Replies
View Related
Jan 18, 2010
I'm trying to obtain the battery temperature, the battery voltage and the battery current. The return value of the code (see below) for voltage and batteryTemperature is always 0 while the others work. I would like to know if there's any other way of obtaining this information and how. Finally, I couldn't find anything in the API for accessing the battery current... Is there any method to know its value? Code...
View 3 Replies
View Related
Jul 28, 2009
I have different text packaged into my app for different locale. The Resource.getString(int resid) method automatically returns me the string for the CURRENT locale of the phone. Is there a way I can specifically obtain resources while passing in a locale? For example, there isn't such method as: Resource.getString(int resId, Locale myLocale);
View 3 Replies
View Related
Jun 25, 2010
I'm developing an image editor for android. In the main activity, I get to show all images by viewing the thumbnails to make the process faster. The problem it's that I need to process the image later and I would get the normal image ID (with the original size, which I think is in MediaStore.Images.Media). I can't get the form of the query. The code that I have is the following but I can't obtain the real image ID (in the IDImage variable) code...
View 4 Replies
View Related
Jul 28, 2010
In the licensing documentation the android developers mention an easy way to more or less securely identify an android device. They are using android.Settings.Secure.ANDROID_ID.
They say they query the system settings for this. But they don't explain this any further.
How do I obtain the android_id and do I need special permissions for doing so?
View 1 Replies
View Related