[q] Question about R. Java - Android Software Development

Is there anyway in Eclipse to have it update the R.java file without having to have a clean build. I am creating the XML files as I go, and am tired of having to comment out code just to have the file rebuild itself.
Also on my one project, the project can't seem to even get the R. Layout. Main to even be read. I noticed it when created the project, in the Main. Java file it had an error. Why does Eclipse have to be so confusing lol.
Thanks for help in advance
Sent from my HTC Desire CDMA using XDA App

You can try turning the automatic building of the application off, then building it when you're ready.
The only problems I ever have is when I go to run a program after a lot of xml changes and it puts a layout_name.out.xml. Then you delete it, close the project, open the project, and clean build.
There is also the saving the xml file to be able to use the view, whatever it may be in the source files.

Thanks for quick reply, what I would like is as soon as I save the XML files it updates the R. Java
Sent from my HTC Desire CDMA using XDA App

this is a problem with eclipse. search these boards for R.java and you will find many people complaining about how Eclipse messes with their project because of some issue with R.java. if you havent tried IntelliJ before you might try that. there are no issues using it with R.java
and the Community Android Edition is free.

So if I understand you correctly, you want to be able to create something in the xml, and have it create it in your class file, which will create it in your R.java file by itself?
If this is the case, I don't think it would work like this. Everything with an id created for you. I know some of my apps, I don't directly interact with some of the views, so I don't need them created. For example, I have a label like textview that stays the same. I don't want it created and throwing up the unused variable exclamation point, nor do I want to waste memory doing it. I think this was the simplest of options, instead of deleting everything you don't use, you just create what you do.
I don't know your level of programming knowledge, so I guess I'll just leave it at that. No disrespect intended, if I have somehow offended you.

j0hnZ said:
So if I understand you correctly, you want to be able to create something in the xml, and have it create it in your class file, which will create it in your R.java file by itself?
If this is the case, I don't think it would work like this. Everything with an id created for you. I know some of my apps, I don't directly interact with some of the views, so I don't need them created. For example, I have a label like textview that stays the same. I don't want it created and throwing up the unused variable exclamation point, nor do I want to waste memory doing it. I think this was the simplest of options, instead of deleting everything you don't use, you just create what you do.
I don't know your level of programming knowledge, so I guess I'll just leave it at that. No disrespect intended, if I have somehow offended you.
Click to expand...
Click to collapse
i believe he means that he has created something in xml with an @+id/something and then when he goes to use it in one of his activities/etc it throws an error because R.java has not been updated with the id of 'something'..

killersnowman said:
i believe he means that he has created something in xml with an @+id/something and then when he goes to use it in one of his activities/etc it throws an error because R.java has not been updated with the id of 'something'..
Click to expand...
Click to collapse
Weird, I've never had that problem.

killersnowman said:
i believe he means that he has created something in xml with an @+id/something and then when he goes to use it in one of his activities/etc it throws an error because R.java has not been updated with the id of 'something'..
Click to expand...
Click to collapse
Basically, it doesn't even recognize it basically. I guess I should just recreate the project and copy paste my stuff
Sent from my HTC Desire CDMA using XDA App

Related

getting a single xml node

Hi guys I'm newbie to android development and I need some help...
I want to make an app that will use data from an xml database and there are two points where I need help cause I find java with xml too complicate...
eg.
Code:
<items>
<1><name>box</name><price>2.00</price></1>
<2><name>pencil</name><price>1.00</price></1>
</items>
1)get a single xml value from a child node(eg.name of 1st item - "box")
2)get an xml database from child nodes (to use it as data source for a listbox) - this one is not nessesary
Thank you for your time guys...
I had never used xml in my programs before android either, so when starting off I found xml a little uncomfortable and found myself wanting to avoid it too. If you take the time to learn how the different xml files are used and how these objects can (easily) be used in your code, I think you'll see why its a lot better to just go with it. It helped things click for me when I understand that every xml object/attribute has a related java object/setmethod, which made me realize how much more organized and simple my code was using the xml.
I don't fully understand what your asking how to do, but it sounds like your trying to "swim upstream" by developing your own system of xml instead of using the android xml namespace. I would recommend doing some reading at developer.android.com, its really not too hard to get your head around and I think it will make your development go a lot more smoothly
Hi guys its me again. I send a lot of hours on searching about an easy way to use xml...
The easier way I have found called DOM but I have 2 questions:
1) how to load files from an android project easily(refered with less command line and without using inputstream)
2) how to use xpath to easily navigate on android
Prefered to see some examples...
Thanks 4 all...

[Q] imaginary project error + programming help

As I mentioned in the previous thread (which may be deleted now), I'm playing with the snake sample game. I was trying to create a menu following this guide (the XML way). I did exactly as the guide says but when I tried to run the project, the console said "main.out.xml: Error parsing XML: no element found".
Now there's an error in the project, but all files seem valid (there's a red cross sign next to the project, but not next to any one of the files). When I try to run the project, it tells me to fix the errors. WTF ? This is driving me crazy
Of course I tried googling, but I found nothing that could help me.
Another thing I wanted to do with the Snake app is change the way the snake is controlled - instead of keyboard I want it to be controlled either by swipe or by the accelerometer. Can any1 help me with that ?
I already got swipe, now off to accelerometer movement.
And any help with the menu thing would be appreciated too.
Guys help me out here. I'm trying to make a menu for the snake app, so one could set up things like max. apples at a time, move delay decrease rate and stuff like that. How should I do this ?
I thought of creating a new activity for the options which will be called from the menu (this menu will be shown after pressing the menu button). Is that a good solution ?
Seriously... WHAT THE **** ?!?!
I create a folder under 'res' named 'menu'. I create a file under 'menu' named 'menu.xml'. I instanly get an error message : 'error: Error parsing XML: no element found'. Now I can do whatever the **** I want (I put some menu items in it), I will NEVER EVER launch the app again, because it says there's an error in the project even though there are NO ****ING ERRORS ! FFFFFFFFFFFFFUUUUUUUUUUUUUUUUUUUUUUUU
grandioso said:
I did exactly as the guide says but when I tried to run the project, the console said "main.out.xml: Error parsing XML: no element found".
Click to expand...
Click to collapse
Are you sure you didn't try to run the .xml file instead of the whole project? When you do that you get an error, a 'main.out.xml' file and your app wont run until you delete it
For the first time I did. But the app didn't run even after I restored everything to the previous state. I had to delete the whole project and create it again.
Now I didn't even press the run button - I got the error right after creating the xml file.
But now I get it - I can create a menu, but I always have to delete the project (keep the files) and create it again. Kinda sucks.
Now please could any1 give me advice on how to handle the snake by tilting the phone ? I googled my ass off, but didn't find anything I could use.
grandioso said:
For the first time I did. But the app didn't run even after I restored everything to the previous state. I had to delete the whole project and create it again.
Now I didn't even press the run button - I got the error right after creating the xml file.
But now I get it - I can create a menu, but I always have to delete the project (keep the files) and create it again. Kinda sucks.
Now please could any1 give me advice on how to handle the snake by tilting the phone ? I googled my ass off, but didn't find anything I could use.
Click to expand...
Click to collapse
Next time you get an error, try simply deleting it from the error log. Eclipse is buggy as hell and sometimes that can fix things (if not the error will just appear again).
As for using the accelerometer, i can't really help you but it looks pretty complicated!
Try looking through the source code of "Amazed" - http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/Amazed/src/com/example/amazed - It may be of some help!
Well if it's complicated then screw it, I don't have much time to funk around.
I'll try the menu, but I'm still not sure if I shoul create an extra activity for the menu. How do I save the settings if I do ?
Meltus said:
As for using the accelerometer, i can't really help you but it looks pretty complicated!
Click to expand...
Click to collapse
That's an overstatement. It's a lot simpler to do than implementing your own listview adapter, for example.
Anyway, all you need to is just let your class implement SensorListener. Then you will need to override two methods; onSensorChanged and onAccuracyChanged. Each are pretty explanatory. Inside onSensorChanged however you will need to check the sensor type, and before you can listen to the sensor you need to register it with the SensorManager (system service). Remember to unregister when you don't need it any more else it will just pointlessly suck battery.
There are many tutorials, but it is really easy to do. Just Google them if unsure, the link posted by Meltus doesn't make it easy to see how it's meant to be used.
OK, first I need to make the menu work.
So first I need to create an activity that extends PreferenceActivity. Then I create a preferences.xml file and an arrays.xml file, that's more or less clear to me.
What bothers me is that I only found 4 types of Preferences - List Preference, EditText Preference, Checkbox Preference and Ringtone Preference. Is that it ? A ****load of apps uses a number choosing preference, where you have a text input a + and a - button - did they all have to create a custom preference type ?
And I have one more dumb question - I just can't for the life of me call the damn preference activity. How do I do that ?
OK, preferences are all done.

Is There Any Registry Editor for Samsung Galaxy S2 Android

hi sry for this dumb question but Is There Any Registry Editor for Samsung Galaxy S2 Android thanks
Only Windows has a registry. What are you wanting to do?
pjfriend said:
Only Windows has a registry. What are you wanting to do?
Click to expand...
Click to collapse
same things i used to do on my old HTC HD2 tweeking wifi and make it little more faster
You might be able to achieve what you want if you have a specific question...
SII has 'N' class radio anyway so it should be a great deal quicker than your HD2.
Ahh , you mean editing the build.prop which resides in system. Must be rooted(stand to be corrected?) and opened through root explorer/ astro/estrongs file explorer
Sent from my GT-P1000 using XDA Premium App
I saw this thread and thought 'Thats the first question I asked when I moved from wm6.5 to android!'. Welcome to Android mate
No, is basically the answer
thanks pjfriend
turborider said:
is that so hard for u to understand what Registry Editor mean? lol
Click to expand...
Click to collapse
Is it so hard for you to understand that system register is Windows-specific? There is no such thing on a Linux, MacOS X, DOS, BSD, Android, iOS, Bada OS, Symbian and so on.
Cheers Brut.all
turborider said:
wow i never thought polish plp have mobile phones in there,dont be smart azz on me dude,i never used android before,bloody hell i wish plp be more helpful than answering crap,i just wanted to know if Yes or No on Registry Editor
Click to expand...
Click to collapse
What's wrong with you? There were like 4 people who told you that there just isn't a registry editor for Android because Android does not have a registry! And you just seem to ignore those people, and insulte Brut.all because of his origin. We don't need people like you in our Android community.
This is getting to be like a monty python comedy sketch LISTEN turborider, there is NO registry, there is NO registry like service or system on android. You can make some modifications using a text editor to build.prop to change some system behaviour.
ice_coffee said:
This is getting to be like a monty python comedy sketch LISTEN turborider, there is NO registry, there is NO registry like service or system on android. You can make some modifications using a text editor to build.prop to change some system behaviour.
Click to expand...
Click to collapse
tyvm matey for your help
Instead of insulting people who try to help, maybe rather actually read the replies properly
Sent from my GT-P1000 using XDA Premium App
please Moderators close this thread sry for my post and ty again ice_coffee
@turborider
Ok, I think I'll explain this further to you.
Windows stores much of its configuration in a system register. Most of other systems, including Android, store config in many configuration files. They're usually textual and human readable, so you could open and edit them using any text editor, even notepad. Usually every installed service/daemon has its own configuration file(s).
This approach has pros and cons over system register. Config files are less standardized: some of them are xml files, others are ini-like or even custom format. So it's quite messy comparing to system register. On the other hand developer could choose format which is most suitable for his needs and you don't need any special software to edit system configuration. Config files are also very simple from technical point of view and this is good.
Unix systems usually store their config files in /etc/ directory. On Android it's /system/etc/ - there you will find a lot of files and you could open any of them, look into, edit, etc. Of course it's not a good idea to do some random changes I don't think you'll find complete guide to Android config files, because every device/ROM is different. Fortunately most of these files aren't specific to Android, but Linux/Unix or some service, so you should be able to find some help in Google.
Happy hacking
P.S.
Yes, we have mobile phones in Poland ;-)
EDIT:
Advanced options for wifi are in /system/etc/wifi/tiwlan.ini, but I'm not sure whether every device uses tiwlan driver. Of course these options aren't the same as in Windows configuration.
Brut.all said:
@turborider
Ok, I think I'll explain this further to you.
Windows stores much of its configuration in a system register. Most of other systems, including Android, store config in many configuration files. They're usually textual and human readable, so you could open and edit them using any text editor, even notepad. Usually every installed service/daemon has its own configuration file(s).
This approach has pros and cons over system register. Config files are less standardized: some of them are xml files, others are ini-like or even custom format. So it's quite messy comparing to system register. On the other hand developer could choose format which is most suitable for his needs and you don't need any special software to edit system configuration. Config files are also very simple from technical point of view and this is good.
Unix systems usually store their config files in /etc/ directory. On Android it's /system/etc/ - there you will find a lot of files and you could open any of them, look into, edit, etc. Of course it's not a good idea to do some random changes I don't think you'll find complete guide to Android config files, because every device/ROM is different. Fortunately most of these files aren't specific to Android, but Linux/Unix or some service, so you should be able to find some help in Google.
Happy hacking
P.S.
Yes, we have mobile phones in Poland ;-)
EDIT:
Advanced options for wifi are in /system/etc/wifi/tiwlan.ini, but I'm not sure whether every device uses tiwlan driver. Of course these options aren't the same as in Windows configuration.
Click to expand...
Click to collapse
ty mate sry for the last post
android options are stored usually (and always for the system's settings) in sqlite3 format and the dbs are around in /data (look for settings.db)
you can edit them on the device via adb shell and sqlite commands, but i suppose there might be some gui for it as well
this is akin to registry on windows, just op just doesn't know the technical differences. no need to be aggressive pricks about it -
Only Windows Operating System has registries. Unix-based one's store configuration files in /etc directory, eliminating the need for a registry.
bilboa1 said:
...this is akin to registry on windows, just op just doesn't know the technical differences. no need to be aggressive ****** about it -
Click to expand...
Click to collapse
+1 to that. A clearly teachable moment wasted by some nasty responses.
@turborider, as already mentioned, the build.prop file can be modified to make some tweaks (and some Android systems might also let you create a file called local.prop that can do some of the same things) but these are not nearly as far ranging as the windows registry. There are many forums and threads which describe the various tweaks and which can be found by searching for ["build.prop" tweaks]. Speaking of searching, for questions like this it is usually more productive to find existing threads covering the topic because such tutorials are likley to have higher traffic than a thread that asks a single question. One simple example of a build.prop tweak that I recently used was to change a value (switching between 1 and 0) which enabled/disabled a particular audio feature (audio offloading, to be precise) while testing a bug in Lineage OS, but there are more significant things that can be done by tweaking the build.prop. There are also other ways to tweak Android OS as suggested by @bilboa1. Search, and you'll find that stuff.

[Q] Noob- GIS / Mapping App - GeoDatabase for Android?

Sorry if this is the wrong place to post, but this is my first jump into android app development-
I'm *trying* to develop a cross platform gis data entry solution for editing shapefile/ geo-database polygon (or point) attributes in the field. Network connectivity can only be relied upon before going to, or upon returning from, the field. Is there an android friendly method for using a (any) type of geo-database file? Right now, I'm planning on exporting polygons to a kml/kmz or similar, and separately export the attributes to sqlite for editing. Upon return from the field, the edited sqlite rows can be used to update the (server-side) geo-database attributes.
However, I would eventually like to be able to directly edit the geometry, but am not sure if this means having to write something from scratch to read from a local geodatabase file, or if some sort of *local* android geodatabase solution already exists.
Just trying to get an idea of the initial direction I should be taking, as I have gis programing and database experience, but haven't ever done any native android development.
Any suggestions or links to related references would be appreciated!
Thanks!
-B
QGIS
You may want to check out this link - http://www.qgis.org/wiki/QGIS_Mobile_GSoC_2011
I don't have any connection to that project.
I'll check it out- thanks. I also spoke with esri, and they will be releasing some android products soon, complete with apis. Certainly not ideal or open source, but probably cheaper than developing my own. Gonna keep trying to develop a simple solution for managing and edditing attributes on my own till then.
Sent from my GT-I9000 using XDA Premium App

[XAP][SOURCE] Native Toast Notification Launcher

This is a very simple application that enables you to specify any kind of Uri to launch. This is done through creating a Toast notification that, when clicked on, will execute the specified Uri. This uses a native method outside of the regular SDK; the standard methods available in the SDK that you'd normally use to create a Toast notification are restrictive in what kind of Uri you can specify. By using the native method not part of the SDK, these limitations can be by-passed.
I've attached both the XAP and the source code. The source project contains three projects:
CShellChromeAPI: The C++/CLI project which calls the native un-documented method
NativeToastLauncher: The .NET wrapper which simplifies the interaction with the C++/CLI project
NativeToastLauncherApp: The test application used to quickly launch any Uri
You'll notice I've hard-coded a default Uri when you launch the application: this will open the Windows Phone 8 "About" page.
To run this, you'll need to side load the XAP which requires a dev unlocked device...
Can I use any system GUID to launch?
djtonka said:
Can I use any sytem GUID to launch?
Click to expand...
Click to collapse
Any registered app GUID yes. You'd do app://GUID/_default (or replace the _default with the particular task to run - in most cases, that's _default).
@cpuguy this is awesome, thanks!
If you guys are looking for GUIDS and default tasks, they are all in the app's WMAppMAnifest.xml. the "ProductID" is the GUID and the "DefaultTask Name" property contains the name of the default task.
Hopefully we can use this to find a program to exploit.
Sent from my Nokia 521 using XDA Windows Phone 7 App
Does anyone happen to have a list of the ID's for the system and settings apps? Obviously, I can't go into the code and get these without messing with the file system. If no one has them, then I can just trial/error until I get some...
If you download the registry hives located at http://forum.xda-developers.com/showthread.php?t=2393883 , you can load the Software hvie and search for "app://" That will give you a few system files you can launch.
EDIT:
I posted a zip file of the default ones in a new thread.
IF anyone has tethering blocked, see if you can get it to work by launching this URI app://5B04B775-356B-4AA0-AAF8-6491FFEA5629/Default
compu829 said:
If you download the registry hives located at http://forum.xda-developers.com/showthread.php?t=2393883 , you can load the Software hvie and search for "app://" THat will give you a few system files you can launch.
Click to expand...
Click to collapse
Im only seeing the app:// function used on the system settings options after going through the regsistries so far.
aclegg2011 said:
Im only seeing the app:// function used on the system settings options after going through the regsistries so far.
Click to expand...
Click to collapse
that's what I saw too. I am having way more luck finding cool stuff in the extracted ffu. Take a look at the zip file in the new thread I started.
compu829 said:
that's what I saw too. I am having way more luck finding cool stuff in the extracted ffu. Take a look at the zip file in the new thread I started.
Click to expand...
Click to collapse
yea, I saw the new thread. Hopefully somebody can find a exploit in all that. It executes some cool files. Too bad there wasn't a cmd.exe file on our phones that we can execute.
aclegg2011 said:
yea, I saw the new thread. Hopefully somebody can find a exploit in all that. It executes some cool files. Too bad there wasn't a cmd.exe file on our phones that we can execute.
Click to expand...
Click to collapse
actually..there is! but it's stuck in a WIM. It inflates it on an "as-needed" basis.
I am hoping that we can use the backgroundworker to run some stuff elevated
compu829 said:
I am hoping that we can use the backgroundworker to run some stuff elevated
Click to expand...
Click to collapse
But they all are pretty much isolated. It is unlikely that you will be able to run anything elevated
aclegg2011 said:
yea, I saw the new thread. Hopefully somebody can find a exploit in all that. It executes some cool files. Too bad there wasn't a cmd.exe file on our phones that we can execute.
Click to expand...
Click to collapse
Not only is there a CMD.exe, but there are other interesting things like a BSOD screen, Control Panel, registry keys referencing desktop (A future exploit I might attempt), and even native EXEs (We knew about native EXEs since WPs release).
Why does this launcher not work with "normal" toasts: {YOUR-APP-GUID} and "/Page1.xaml"? Only with empty GUID and full path.
Similarly, any chance this could be used to open arbitrary XAML pages, rather than just the ones defined in the app manifest? For example, something like what was posted in another thread (http://forum.xda-developers.com/showpost.php?p=45265419&postcount=56) using the following URI: app://5edbdbbc-2ab2-df11-8a2f-00237de2db9e/_default#/View/APNSettingPage.xaml to launch a hidden page in the Connection Setup app. I don't know if that's a weird behavior of CS or if its universally possible (and while it feels lazy to ask, I'm at work right now). There are a bunch of "hidden" pages in the ATIV S Diagnosis app, some of which would be very useful, but the navigation code for them is blocked or outright missing. If we could invoke those directly... There are probably a bunch of other such hidden gems in other OEM apps too.
Yes you can. The way I found the one in the HTC app was by loading the dlls in JetBrain's dotPeek. Then I looked for the xaml files. It is all a relative URI based on what dotPeek/the app "sees". The only thing the manifest states is where the default entry point is for the page. Basically I looked in the manifest file for how it calls the "default" page. and then replace it with the relative URI for the other page you want.
If you guys want, I can write up a simple tutorial. I just have an HTC 8x, so my hands are tied. If someone can figure out how to deflate an nbh file so I can browse it, that'd be fantastic! I found a "dead" 521 on eBay that I am thinking of picking up for research since there are way more tools for Nokia.
compu829 said:
Yes you can. The way I found the one in the HTC app was by loading the dlls in JetBrain's dotPeek. Then I looked for the xaml files. It is all a relative URI based on what dotPeek/the app "sees". The only thing the manifest states is where the default entry point is for the page. Basically I looked in the manifest file for how it calls the "default" page. and then replace it with the relative URI for the other page you want.
If you guys want, I can write up a simple tutorial. I just have an HTC 8x, so my hands are tied. If someone can figure out how to deflate an nbh file so I can browse it, that'd be fantastic! I found a "dead" 521 on eBay that I am thinking of picking up for research since there are way more tools for Nokia.
Click to expand...
Click to collapse
That's correct. I have been navigating to various - normally unreachable - XAML pages in quite a few of the Nokia apps. I gave an example of that in a different thread:
Code:
app://[COLOR="Navy"][B]2377fe1b-c10f-47da-92f3-fc517345a3c0[/B][/COLOR]/[COLOR="Orange"][B]_default[/B][/COLOR]#/[COLOR="Green"][B]Launcher[/B][/COLOR];component/[COLOR="DarkRed"][B]MainPage.xaml[/B][/COLOR]
In this example, I launch the Nokia extras+info app (2377fe1b-c10f-47da-92f3-fc517345a3c0) with the default entry point (_default) which, as @compu829 stated, can found in the app's manifest. Following that, you can add "#/" (not sure if either the hash-tag or slash can be taken out or both are required to work but I know with both, it does work) to the URI to specify a particular XAML file you'd like to open. Following the "#/", you get to specify the assembly (i.e. the .DLL in the XAP file) in which the XAML file is located (Launcher). And finally, you add ";component/" followed by the full path to the XAML as defined in the embedded resource file (MainPage.xaml).
-W_O_L_F- said:
Why does this launcher not work with "normal" toasts: {YOUR-APP-GUID} and "/Page1.xaml"? Only with empty GUID and full path.
Click to expand...
Click to collapse
I presume your reference to the "empty GUID" is for the first parameter of my static Launcher.LaunchToast method? That first parameter is, as far as I can see, ignored for the actual toast launch. If I'd have the signature of the "Shell_PostMessageToast" method, I could perhaps understand what it does but, without it, I just knew it wanted a GUID (passed to it as a string) and that that GUID could be an empty one. I reversed engineered the signature from that native method (found in ShellChromeAPI.dll) by taking a look at another native assembly calling it. Naturally, this only tells shows me how that method is being called but doesn't return the name of the parameters. If I remember correctly, the assembly calling that method was passing its own application GUID... I could have done the same but, I didn't see what use it had so I decided to keep passing it an empty GUID.
The format of the toast is different most likely because that's the raw toast launching method. The other format you're used to is the more developer friendly one that's sanitized prior to launching it (so you can't launch another app directly).
Success!
@GoodDayToDie , this is exactly what I'm trying to do! And here is result:

Categories

Resources