[IDEA] User agent customized by page - Nexus One Android Development

I was thinking last night: wouldn't be it be awesome if we could customize the browser's user agent so that a certain page would load a specific user agent? There are often pages that I want loaded in desktop mode, and it's a little annoying to constantly have to go back and forth to change it.
I figure the best way would be to have a user-defined database containing domain names and their preferred user agent. The browser would run a quick cross-reference between the input domain and the database to see if it's listed. If it is listed, change the user agent to the defined one. If not, use the currently defined user agent.
I REALLY want to be a part of this mod. I have no Java experience whatsoever but I'm a quick learner and want to try it out. Can someone point me in the right direction? Where can I find the source for the browser/good resources for Java?
Thanks!

No one?

I had this idea a while back and think it would be fairly easy, albeit tedious, to accomplish.
in cyanogenmod, the browser code is at: packages/apps/Browser/src/com/android/browser
you'd have to
build the UI to customize the UA for a given domain & set the prefs in the db
check the URI against the prefs prior to initiating the download
if match is found, use per-site setting; else use general setting

alapapa said:
I had this idea a while back and think it would be fairly easy, albeit tedious, to accomplish.
in cyanogenmod, the browser code is at: packages/apps/Browser/src/com/android/browser
you'd have to
build the UI to customize the UA for a given domain & set the prefs in the db
check the URI against the prefs prior to initiating the download
if match is found, use per-site setting; else use general setting
Click to expand...
Click to collapse
Finally! Thanks for the reply. I'll look it over when I get home.

rickytenzer said:
Finally! Thanks for the reply. I'll look it over when I get home.
Click to expand...
Click to collapse
This is a good place to start: http://github.com/CyanogenMod/android

Started looking around at the code. Looking at BrowserSettings.java and I see where the UA gets selected. The goal is to now figure out where userAgent gets set.

Related

How to change the User Agent String setting on stock Android Browser

A while ago I found a tip somewhere on how to get to some additional hidden android browser settings including how to change the user agent string so that the browser would identify itself as a desktop browser or iPhone browser while surfing.
This setting is reset between sessions, I didn't use it frequently and eventually forgot how to go about making the change.
Recently I had a need to access these hidden browser settings again and it took quite a long and frustrating search effort to finally locate this information which does not seem to be widely publicized. So, in an effort to save anyone else this trouble, I figured I would post the information on how to do this on a couple Android boards that I frequent and also include a few words that might be picked up as search terms for anyone else trying to find this info. The procedure is very simple. I currently have an HTC Sprint Hero running Android 1.5, so I'm not sure what other devices or builds this will work on...
Open the Android web browser. In the address bar enter 'about:debug' where you would normally enter a URL and hit enter or Go. Be sure to erase the 'http://www.' that the browser likes to leave in the address bar for you. No page will load and you may or may not get a pop-up message 'Debug mode'. But if you now go to Menu > More > Settings in the browser and scroll to the bottom of the list, you should see a new group of options under the 'Debug' heading. The bottom setting is 'UAString' and if selected will give you the option of enabling your browser to identify itself as Android, Desktop or iPhone. Results after making this switch have been mixed, but go ahead and give it a try if you have a need to. I'm not sure what the other options do, so use at your own risk.
Feel free to leave a reply if you found this information helpful, or if it does or does not work on your particular device / build.
search terms: Android Browser Hidden Debug Settings Change User Agent String Identify Desktop Firefox iPhone about:debug UAString
way to go, thank you for the information. might come in handy.

Looking for Developer to...

Hi.
I was wondering how hard it would be to create a simple application that would connect to a server or website checking for updates. I plan on loading font .apk's on the server or website, and would like a application to periodically check for updates or manually check for updates, be able to preview the font, and then download the .apk if wanted. How hard would it be to create such an application?
Thanks.
Jzero88
jzero88 said:
Hi.
I was wondering how hard it would be to create a simple application that would connect to a server or website checking for updates. I plan on loading font .apk's on the server or website, and would like a application to periodically check for updates or manually check for updates, be able to preview the font, and then download the .apk if wanted. How hard would it be to create such an application?
Thanks.
Jzero88
Click to expand...
Click to collapse
Well, this depends on how you approach it, but I think the easiest way to do this would be to create a feed using XML. So if you were doing your font updater, you would load a file like this:
<FontDetails>
<Font name = "Font1" example = "http://www.myfontsite.com/FontExamples/Font1.png" location = ""http://www.myfontsite.com/Fonts/Font1.apk"\>
<Font name = "Font2" example = "http://www.myfontsite.com/FontExamples/Font2.png" location = "http://www.myfontsite.com/Fonts/Font2.apk"\>
</FontDetails>​
The problem with this is that you will have to maintain this XML file, making sure its always up-to-date(Easily manageable with some simple scripts).
If you aren't willing to do this, you could go down the road that is wrongly mislabeled as "The Easy Way" and hard-code the locations of all your APK's and all of your example images, but I would only do this if you were planning on dumping all the APK's and images in the same place(For example, if all your APK's were here: http://www.myfontsite.com/Fonts/). You would request the directory information from the server and parse that into your list of font APK's and correspond them with their example images(probably by naming them the same; i.e. Font1.apk and Font1.png).
If you decide to use the first option, you could do a bunch of cool things with the organization, like break things into categories and apply taggings and it would only require one request to the server per update. If you go with the second method, organization is guaranteed to be a mess if you try anything large scale, and adds a layer of complexity if you try to break things into folders and categories. This would require a ping per folder you have to check, which can have a high complexity factor if you have a lot of folders.
I just want to point out that even though this is directly related to development, this is a type of question that belongs in the General section(Questions ALWAYS belong in General). I'm sure a Mod will come around, scold you, then move the thread.
Anyway, I do hope this helps,
Good luck,
Tyler
Edit: Having a bit of problems getting the XML looking correct. Sorry if it looks ugly :S
Even easier would be to manage the updater as an RSS feed. Then it becomes quite trivial, as there are several examples of RSS readers online already.
Great! Thanks for the reply!
Yeah, the XML approach I think would be the better option as well, just because we could use this thread to hold everything I currently do no have any hosting at this time. Would you be up to making such a application? It seems you have the know abouts to so.... I would be the one to maintain everything and update it. I would monitor this thread and when new ones pop up, I wouldn't mind adding it to in the XML.
Also, how would the RSS feed work?
Thanks
jzero88 said:
Great! Thanks for the reply!
Yeah, the XML approach I think would be the better option as well, just because we could use this thread to hold everything I currently do no have any hosting at this time. Would you be up to making such a application? It seems you have the know abouts to so.... I would be the one to maintain everything and update it. I would monitor this thread and when new ones pop up, I wouldn't mind adding it to in the XML.
Also, how would the RSS feed work?
Thanks
Click to expand...
Click to collapse
Wish I could...I've got about 50 projects already on the back-burner and no time to finish them Tell ya what though...I've finished a mini project a couple weeks ago with some buddies at school for my friends website. Its an Open-Source RSS reader that was made to read in the latest articles of his site. With some slight tweaking, I'm sure you(or some other dev) could mod it to work in your favor...Here's the github address:
http://github.com/pencilo/Absolute-Android-RSS.git
I don't think this is the latest code, but all the working elements you need are in here.

Looking for Custom Quotes Widget

I'm looking for a very simple app. It allows me to go in and add quotes, I have an extensive txt file of my favorite quotes. The ones I find inspirational or motivational or thought-provoking etc. I want to populate the widget with that.
Every app I found was populated from other sites based on category, etc.
Anyone know where I can find it?
Alternatively a widget which pulls from a url and displays the returned text (I'm a web developer and haven't learned android dev. yet.)
Cheers
this probably won't meet all your needs but give it a go. http://www.appbrain.com/app/23-000-great-quotes/com.cramzy.quotes
trickjarrett said:
I'm looking for a very simple app. It allows me to go in and add quotes, I have an extensive txt file of my favorite quotes. The ones I find inspirational or motivational or thought-provoking etc. I want to populate the widget with that.
...
Click to expand...
Click to collapse
Such an app would be really great!!
So, now there is an nice App for this: "PersonalQuotes", exactely what I was looking for! Works perfect, have a look! you will find it in the Market
have a look to my new app
trickjarrett said:
I'm looking for a very simple app. It allows me to go in and add quotes, I have an extensive txt file of my favorite quotes. The ones I find inspirational or motivational or thought-provoking etc. I want to populate the widget with that.
Every app I found was populated from other sites based on category, etc.
Anyone know where I can find it?
Alternatively a widget which pulls from a url and displays the returned text (I'm a web developer and haven't learned android dev. yet.)
Cheers
Click to expand...
Click to collapse
Hi,
Please have a look to my app. download link is there in my signature..
Quote widget for android- app updated
Check out : https://play.google.com/store/apps/details?id=com.bhanu.bhanuquoteoftheday
its updated from scratch, new simple and smooth UI with complete overhaul from scratch.
try and let me know your feedback.
trickjarrett said:
I'm looking for a very simple app. It allows me to go in and add quotes, I have an extensive txt file of my favorite quotes. The ones I find inspirational or motivational or thought-provoking etc. I want to populate the widget with that.
Every app I found was populated from other sites based on category, etc.
Anyone know where I can find it?
Alternatively a widget which pulls from a url and displays the returned text (I'm a web developer and haven't learned android dev. yet.)
Cheers
Click to expand...
Click to collapse
I don't want to start new thread, but there are some news about Quotes App/Widget with syncing to/from a cloud?
I looking for this regularly from 2-3 years and didn't found any good.
How can I delete all your 4097 quotes in just one click? All I want to add just my qu
yogi.306 said:
Check out : https://play.google.com/store/apps/details?id=com.bhanu.bhanuquoteoftheday
its updated from scratch, new simple and smooth UI with complete overhaul from scratch.
try and let me know your feedback.
Click to expand...
Click to collapse
How can I delete all your 4097 quotes in just one click? All I want to add just my quotes. Thank you.
I love your APPS however I cannot modify it.
There is no way right now to delete all quotes.
and we wont add that in future. as no need of such option.
engrbugs said:
How can I delete all your 4097 quotes in just one click? All I want to add just my quotes. Thank you.
I love your APPS however I cannot modify it.
Click to expand...
Click to collapse

[REQ] Opera Mobile 9.7 User Agent Cab

I found this intersting topic
http://forum.xda-developers.com/showthread.php?p=5786377#post5786377
"I've figured out how to get Opera Mobile 10 Beta 3 to only display websites in desktop view without getting redirected to a mobile version of the site. UPDATE: Works in Opera 10 Final too!
The first 2 steps are pretty common knowledge, but they don't work for all sites. It's the 3rd step that makes every website work for me.
Step 1: Set a custom user agent string
This tells websites what kind of device you are using to browse the site (desktop computer, smartphone, etc).
Goto opera:config -> User Prefs -> Custom User-Agent
Find a desktop user agent string, type it in, and save. I'm using the one from my Firefox browser on my home desktop (it can be found by clicking Help -> About Mozilla Firefox). Mine looks like this:
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)
You can use whatever string you can find that works. I've even seen people use an iPhone user agent to get iPhone versions of websites.
Step 2: Spoof a user agent ID
This tells websites what client you are using.
Goto opera:config -> User Agent -> Spoof User Agent ID
Type in the number corresponding to a browser to identify as that browser
Global values:
1 = Opera
2 = Mozilla
3 = Internet Explorer
Site-specific values:
4 = Mozilla, Opera not mentioned
5 = Internet Explorer, Opera not mentioned
Don't forget to save. I have mine set to 2, so websites think I'm using Firefox
Step 3: Set custom HTTP_Accept parameters
This one is hard to explain, but it basically tells the website which versions (i.e. desktop or mobile) are acceptable for viewing.
Goto opera:config -> Network -> HTTP Accept
Type this in exactly:
text/html, application/xml;q=0.9, application/xhtml+xml, application/x-obml2d, multipart/mixed, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1
Please note that this is just the default entry minus the one element that allows for mobile/wap viewing.
Also in the Network section, go to HostName Expansion Prefix and delete wap from the list. Remember to save. Exit the browser and everything should work like a desktop from now on! You can go to www.whatsmyuseragent.com to check and see if everything is right. If you still want to view mobile versions of sites, you'll have to type in the specific mobile URL for that site (I keep mobile versions of my bookmarks just in case I get stuck on EDGE or a slow connection).
Hope this helps! If anyone with web-coding experience would like to explain further or correct anything I did wrong, please be my guest!"
by Eman3000; thx!
It's really useful and it does work everywhere.
However it takes ages to do it everytime.. can anyone make this process a lot faster? like write a .cab and/or a .reg?
Thanks
Loved it!
Been looking for alternative browser for this sole reason. Nice and easy workaround (with proper credits given and a link to the source... you rock). Thanks for the share.
The opera repo thread is riddled with so much "spam" posts that I'm sure I'd have never found it. Definitely the most useful hack I read in quite a while.
EDIT: I used this in Opera 9.5. Did some digging and this info seems to be stored in opera.ini (stored in Application Data in Opera's folder... don't know if this is a constant over versions) which somewhat makes the cab method unfeasable (considering that it would affect all of the other user settings...). Also compared complete registry dumps and nothing was changed so the reg method is out. Would be however possible to Mortscript this (may need to be adapted according to Opera version which could be a pain).
EDIT2: Searched xda and found this. Took a peek with MSCEInf and found these cabs just change a few lines in the registry (no files). No for my version but may interest you.
you also can use my free software "UA_Change" :
http://www.i900playeraddict.com/corwin.php?soft=evb_ua_change
or here :
http://forum.xda-developers.com/showthread.php?t=848812
All Opera Mobile/Mini versions: Official thread
Yes, there is great information collected in here, have a deep read to 1st page
frmariam said:
Been looking for alternative browser for this sole reason. Nice and easy workaround (with proper credits given and a link to the source... you rock). Thanks for the share.
The opera repo thread is riddled with so much "spam" posts that I'm sure I'd have never found it. Definitely the most useful hack I read in quite a while.
EDIT: I used this in Opera 9.5. Did some digging and this info seems to be stored in opera.ini (stored in Application Data in Opera's folder... don't know if this is a constant over versions) which somewhat makes the cab method unfeasable (considering that it would affect all of the other user settings...). Also compared complete registry dumps and nothing was changed so the reg method is out. Would be however possible to Mortscript this (may need to be adapted according to Opera version which could be a pain).
EDIT2: Searched xda and found this. Took a peek with MSCEInf and found these cabs just change a few lines in the registry (no files). No for my version but may interest you.
Click to expand...
Click to collapse
Glad it helped!
the setting are stored in "opera.ini" you said..
how about a banal copy-paste from the old ROM to the new one of this file?
I also use opera 9.7, latest build. Are the setting still stored in the opera.ini file?
EDIT: Someone says yes.. someone no.. mhmhm... Anyone has a proven answer pls?
What's Mortscript?
Corwin9S said:
you also can use my free software "UA_Change" :
http://www.i900playeraddict.com/corwin.php?soft=evb_ua_change
or here :
http://forum.xda-developers.com/showthread.php?t=848812
Click to expand...
Click to collapse
What you said changes only the UA
In the process I wrote in the first post there's other tricks not related to the UA setting. Also I don't speak french
but thx.
orb3000 said:
Yes, there is great information collected in here, have a deep read to 1st page
Click to expand...
Click to collapse
looked as deep as I could.. didn't find anything answering my question.. lol
So, opera is the best brower for android. I solved the problem by this way too. Thanks you for your tip, and opera too.
you the man
you are freaking awesome.. i would need a degree in networking to be able to do those stuffs
thank you

Best practice for storing configurations

Hello everyone,
I'm new to Android development. I've written my first little "get my feet wet" ap and am looking to expand on it. One thing I would like to do it give the user more options of things they can configure and I'm wondering about the best way to store that information.
At what point does it become worthwhile to start using mySQL vs just using string data in the prefrences? Or is there another option I've missed (maybe an xml file, but I'm not sure where that would be stored?).
In my case, I'm thinking I have fewer than 100 instances of an object (or objects) that would have 3 or 4 properties associated with them.
Thanks!
Use the SharedPreferences class, is the easiest way to achieve your goal (BTW, SharedPreferences generate a xml file to storing your preferences).
SharedPrefrences is what I used for my basic version, but my understanding is that it allows for name-value pairs right? That works well when you have a predetermined set of prefrences, but what if it's more fluid?
Say I want to allow the user to configure his widgits, and each widget has a number of properties - say "color", "number", and "size". Maybe one user will configure 3 widgets and another user might configure 25.
I can think of a couple of different ways to parse this out into name-value pairs, but is that the best way?
Yep... for me that is the best way. For each user you can put the values using someting like this:
UserName+WidgetID+"PreferenceName"
And thats all... the preferences will be unique for each case, without parsing and 0 errors
Ok, cool. That's one of the options I had considered but didn't know if that would be the most efficient. Of course I'd also have to have a list of all the "Widget ID's" stored in a preference to loop through as well.
I assume the maximum amount of data that can be stored in one prefrence is just whatever the Java max string length is...is that correct?
Yes, you're right

Categories

Resources