Android : WebView UserAgent (without Having A Context)?
Dec 15, 2009
I am downloading web pages off of the Internet and some of those sites want to format their content for the actual user agent used.
I want to use the user agent that is later on used to display the stuff I download.
I can ask WebView.getWebSettings().getUserAgentString() to get the user agent, but this doesn't work all that well for my app as I need to instantiate a WebView first even though I don't need. Furthermore to do that I need to have a UI context, which I don't as this part of the app doesn't have a UI.
Is there another way to get to the User Agent?
I found in WebSettings:
// User agent strings. private static final String DESKTOP_USERAGENT = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en)" + " AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2" + " Safari/525.20.1"; private static final String IPHONE_USERAGENT = "Mozilla/5.0 (iPhone; U; CPU iPhone 2_1 like Mac OS X; en)" + " AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2" + " Mobile/5F136 Safari/525.20.1";
But of course, this is private. Any other idea?
View 3 Replies
Nov 6, 2009
Is there any way to launch a context menu on the links in a WebView that knows about the links it is launched upon? I would like to launch a context menu on links that I can then open in the actual Android browser or send the link by email etc.
View 4 Replies
View Related
Mar 8, 2010
I'm trying to add custom menu items in a WebView Context Menu. Unfortunately, my items are shown in the menu of the first web page I load , but then if I load a second page, a long press only shows the standard context menu items. Mine are gone. I've put a Toast inside the code and it is displayed as well on the first loaded page, but not on the second. I'm using the code below:..............
View 6 Replies
View Related
Jan 21, 2010
How can I launch a contextmenu from a contextmenu? I'm trying to replicate the MediaPlayer action that happens when you long click a song, then click "Add to playlist" in the resulting contextmenu. When you click that menu item, another contextmenu pops up with "Add to playlist" as the title, and "Current playlist", "New", and however-many-playlists-you-have defined after that.
View 4 Replies
View Related
Jul 19, 2010
I'm confused about the concept of the Context class. I see that it's a base class of Activity, but the Android docs also mentions the Context storing global information about the app environment. So in my app which has 3 activities, does that mean I have 3 distinct Context objects, or do they actually refer to 1 entity? Also, what is the lifetime of a Context object- does it live until the last component of this activity's process is garbage collected?
View 1 Replies
View Related
Nov 24, 2010
i have got a stupid question to ask. I created a custom ContextMenu. But when i call the menu, the menu displayed will also have the default menu added in. Is there anyway for the default ContextMenu not to appear as well?Code requested: @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
menu.setHeaderTitle("Recipients");
inflater.inflate(R.menu.menu_contacts, menu);
View 1 Replies
View Related
Jan 4, 2010
Is there a way to get the current Context instance by using a static method? I'm looking for that way because i hate saving the context instance each time it changes.
View 1 Replies
View Related
May 15, 2009
When you are developing on an application level(Services, Activities) you always get this Context reference automatically. But what if I am on a lower level and developing a program started with app_process, how can I get hold of a Context then? Its a huge part of the API that need this context. What the proper way to create a Context instance?
View 7 Replies
View Related
Jun 12, 2009
In an Android app, is there anything wrong with the following approach..
View 4 Replies
View Related
Oct 10, 2010
I often run into the following dilemma: I need some singleton-like object in my app (typically some central manager-like thing) and this object needs a context for various things. This means that I either have to pass a context to all methods needing one or have some sort of init-pattern to the object. Neither is pretty I think. What is the correct way of doing this? Or is this simply (even the definition of) a Service?
View 15 Replies
View Related
May 3, 2010
I'm considering creating a singleton wrapper for a Context so my model objects, if necessary, can open and read from a database connection. My model objects do not have access to a Context, and I'd like to avoid needing to pass a reference to a Context from object to object.I was planning to place into this singleton a reference to the Context returned by Application.getApplicationContext(). This singleton object would be initialized in my custom Application instance before anything else would need to or have a chance to use it.Can anyone think of a reason to not do this?
View 3 Replies
View Related
Jul 19, 2010
What is the lifetime of an app's global android.content.Context object? Does it last until the last component of the app is terminated by the Android runtime?
View 2 Replies
View Related
Jun 18, 2009
Hi! I use dialog with multipleChoiseItems. Is there any way to create context menu for list of the items?
View 2 Replies
View Related
Apr 20, 2010
I have a ListView with a ContextMenu, it has one CheckBox (the CheckBox has android:focusable="false") and one TextView per row, but you can hide the TextView in the preferences menu. After doing that, the CheckBox wasn't registering the ContextMenu, so of course, why not register For Context Menu(cb) and unregisterForContextMenu(getListView())? Yes, i did that, but then, when when i call the delete command of onContextItemSelected, the app crashs. AdapterContextMenuInfo info=(AdapterContextMenuInfo)item.getMenuInfo(); db.deletarTarefa(info.id);
View 1 Replies
View Related
Aug 30, 2010
So I'm working on a service that will handle requests to send data to a socket.I've done socket programming in a service before, but only within the same application. I'd like this to just sit and do nothing until any application wants to give it data to send. That's all well and good.I have register an intent filter and the usual stuff and can process the data. But I want to process the data coming from different activities in different threads (subsequent calls from the same application will be computed on the same thread).Is there a way to get the calling package or app or whatever? I'd prefer not to require passing in an identifier as an extra to prevent spoofing. (It's not a serious security concern, it's just each application needs its data processed in the order that it's received.)
View 1 Replies
View Related
Mar 7, 2010
I have a context menu option that, when clicked, will load some information from the web and insert it into a database.So this is a lengthy process and I would like to display a progressdialog over the top of the context menu when this option is selected.I've got the progressdialog running now, but it won't show up.It's almost like the context menu is covering it.So is there a way that I could get the progressdialog to show up on top of the context menu and be visible to the user.
View 2 Replies
View Related
Nov 8, 2010
I have created one music app. In this app, i have loaded albums dynamically by using URL request and displayed as table layout. For each table row i registered context menu. But when the context menu is appeared by long press on each table row i could not find on which table row the context menu is appeared. If anyone know please guide me to solve this problem.
View 2 Replies
View Related
Dec 10, 2009
I have a ListView with 5 items. Each of the items can be long pressed to open a Context Menu. The Menu has 5 options and I want them to be selectable, by having a check box. I know of the multiple choice listview but was not sure how to have this checkbox feature in a ContextMenu.Does anyone know if this is possible and if so, how?
View 4 Replies
View Related
Nov 12, 2010
Can I add a new item in SMS context menu which can in turn invoke my app/activity?
View 2 Replies
View Related
Jul 26, 2010
I have a context menu that starts to do some calculations when you press one of the context menu items.While the calculations are made I have a progressbar that I want to show. The progressbar is called from the calculations() method. The problem is that I can only see the context menu while the calculations are being made and the phone is more or less frozen.
View 3 Replies
View Related
Feb 7, 2010
if google voice is installed on your phone, when you dial a phone number a context menu pops up asking if you want to dial with or without google voice. I would like to accomplish the same task for dialing a number or sending a text message. Does the API allow you to do that?It seems there is a process_outgoing_calls, in the permissions manifest, but is there anything for the SMS?
View 2 Replies
View Related
May 14, 2010
I'm trying to add a context menu to my ExpandableListView. I've implemented onCreateContextMenu() and onContextItemSelected() but if I hold my finger on a menu item context menu doesn't appear. What's my mistake?
View 1 Replies
View Related
Feb 15, 2010
I'm trying to handle exceptions at a global level. My understanding is that the only way to do this is with an UncaughtExceptionHandler. However, this reduces one to the primitive java file and network i/o packages. I'd like to be able to broadcast an intent or bind to a service. Is there some way to interact with the android packages to retrieve a context in a static manner? I could probably do some hack workaround with a thread local, weak-referenced context set at the time of the exception handler, but I'd rather avoid that nastiness.
View 4 Replies
View Related
Aug 22, 2010
I have a ListActivity with a list of names (Jacob, Will, Matt, etc.). I have a contextMenu which gives the user the option to edit or delete the person. I know how to find the id to perform the edit and delete functionality, but I can't figure out how to get the person's name to be added to the intent extras or to add a toast when a delete occurs.
Here is a snippet of code that I'm using for the context menu: Code...
View 2 Replies
View Related
Nov 13, 2010
I've been working at this all day, and I'm really close but just can't get this to work. I have a button that pulls up an AlertDialog populated with saved entries that include Name and Price. Right now, I can click an item in the Dialog and have it automatically fill in the Name and Price fields in my activity. I want to also be able to long press an item and receive an option to delete it. This is my first try at an Android app, and a lot of this is repurposed from the Notepad Tutorial. Two things I can't figure out:
1) Is my registerForContextMenu sufficient/correct?
2) What am I doing wrong with my onCreateContextMenu? Code...
View 1 Replies
View Related
Mar 2, 2010
In an activity it's (usually) easy to get the Context.
What if I am working with a home widget class?
These are classes that extends AppWidgetProvider, which don't contain a Context!
View 1 Replies
View Related
May 21, 2010
If you extend SQLiteOpenHelper, for the Constructor you have to use a Context. I am wondering if there is a way to leave this out, and be able to work with database tables without a Context.
Or at least be least restrictive, I mean a way of project/class structure that will make history the several context passings I have to do now.
As it is my application has several level of classes, chained in each other, and there are a few that connects to the database, but have no whatsoever influence on the interface, so they don't actually need the Context.
Are you creating your classes in the way that you pass each time a Context to them?
If not, how you do, how you reuse a Context in a short class?
View 1 Replies
View Related
Jun 11, 2010
I want to view two listviews at the same time. This is not the problem!
What I don't know if it's possible is if I can have two different context menus for the two lists? And second, is there a way to check in which of the two lists the user has selected an item?
View 3 Replies
View Related
Mar 3, 2010
I have a class defined as
public class viewGroups extends ListActivity
Somewhere in the class I have
objItem = new clsContactGroups(context);
I am wondering what is advised to be used here? Which context?
I know four choices, but maybe there are others...
this
this.getApplicationContext()
this.getBaseContext()
this.getParent()
I use this Context to show a Toast. So I would like to show on the front-most view visible.
View 1 Replies
View Related
Sep 14, 2010
I am using WebView in an ActivityGroup and it will throw an exception if WebView show Dialog and complain the activity is not valid. But it's okay if I set the context of the WebView to the TOP activity. So I wish to know how to set the context in the layout xml ?
View 2 Replies
View Related