Android :: Long-running LoadUrl() JavaScript With A Callback
Sep 21, 2009
I'm planning to use the JavaScript interface to Java, to connect to Java methods that go to the network (or some other long-running function) and deliver the results via callback.
The flow is: 1. User clicks on a link in the WebView, which calls my Java code. 2. My Java code posts a worker Runnable to a Handler, and returns immediately. 3. The worker goes to the network, then makes a callback to the WebView.loadUrl("function('result')") to deliver the result.
I made an example that sleeps inside the Runnable. The entire WebView becomes unresponsive! What is the proper way (if any) of implementing a long-running JavaScript call?
Is it safe to call loadUrl() from multiple threads?
View 4 Replies
Aug 5, 2010
I would like to disable the context menu that appears after a long tap (touch and hold) on images in my web application. I've seen posts with different ideas how to do it, but none of them seem to work for me.
Is there a way to do this on Android via HTML/CSS/Javascript?
View 3 Replies
View Related
Aug 28, 2009
I'm trying to pop up an AlertDialog when someone long presses a list item.What I end up with is nested callback objects.I'm not sure if that is the problem but simple Alert dialog examples are not working for me.
View 3 Replies
View Related
Jul 27, 2010
I have an app that has a service with it. This service is started the first time you open the app is is suppose to run continuously in the background every two minutes. It seems that at some point though the service stops running or alarmManager stops scheduling/doing what is requested of it. Here is a breakdown of my code flow.
User opens the app,. Service is started, Inside the service I cancel any alarms that might be for this app then create a new one set for two minutes out, Once the alarm is set I call a GPS location check to get lat/lon, I then call up a .net web service to do some stuff with the lat/lon, Once text is returned I check that text for certain Items, If a certain item is found I send a broadcast out to a receiver that then creates a wakelock, starts a new intent to open an activity of my app then sounds an alarm, Right after I broadcast I call stopSelf() as well as calling stopSelf() if the text did not contain certain Items, I call finish() on the new activity I started if we go that far once the Active screen of my app is closed.
The reason I think something is dieing out here is because after some point in time usually once I wake up in the morning and check the phone I no longer see my GPS icon on my droid checking every two minutes.
View 2 Replies
View Related
Nov 9, 2010
I am doing an application in android which requires to know for how long the application is running. Do anyone know how to retrieve such information??. Is there any way where android provides the information about the running applications ,from how much time they are running?
View 3 Replies
View Related
Jul 24, 2010
I have an AsyncTask that scans the file system and publishes progress through Notifications. To do this I need a reference to the current Activity in the AsyncTask.
I also don't want to kill the task when the activity is destroyed. How do I avoid leaking the activity and everything it references on each configuration change?
One possibility is to remove the reference in OnPause() to be sure it is gone when the Activity is destroyed, but that would mean notifications stops coming as soon as you leave the activity which is no good.
Isn't there a recommended way of dealing with AsyncTasks in this way?
View 12 Replies
View Related
Sep 26, 2009
How to programmatically stop a long-running query?
The long-running step is, for example, the first call to Cursor.moveToFirst(). This can sometimes take up to 30 seconds so I would like the user to be able to cancel.
However, how should this be done? I've tried closing the Cursor (in another thread) but all that happens is that the close() call takes as long as moveToFirst() and then terminates with the exception:
java.lang.IllegalStateException: attempt to acquire a reference on a close SQLiteClosable
View 10 Replies
View Related
Aug 11, 2010
I JUST had to restart my phone for the first time (some weird lagging started). It had been running since two days after launch (when I received it from letstalk.com)
View 2 Replies
View Related
Aug 26, 2010
I am wondering how does webview load a particular URL. Does it create a new thread or load the URL in the same thread i.e. UI thread? The reason I am asking this is I am facing some weird wakeup lock issue when I launch an Activity from current Activity (in current Activity's onCreate method) which creates a WebView in it's onCreate method and loads a URL using loadUrl method. So when I am done with this activity and go back to the Activity which launched this is restarted because wakeup lock time was expired.I googled it and found out that if onCreate method of an Activity takes too long then this type of issue might occur. Have any of you faced this kind of issue involving a WebView? Any kind of help would be really appreciated.
Here is sample code.Activity A:
CODE:.........................
View 1 Replies
View Related
Oct 4, 2010
In my Android game I am loading websites in WebView by calling webViewRowA.loadUrl(www.website.com) and after some time (random) the device crashes with the following traceback.
CODE:..................
View 2 Replies
View Related
Nov 2, 2010
How do I open a a local html-page (named, for instance "test.html") in a WebView? where should i keep this keep html page with images in project and how to use Webview.loadUrl(String url)?
View 4 Replies
View Related
Aug 21, 2012
Within the last week my tablet stating running very slow.
Pages take a long time to load Apps take forever to load Apps crash every other time I open them.
I thought it was my router (netgear n600) but my iPad and cell phone.
View 13 Replies
View Related
Sep 1, 2010
I came across an interesting issue when testing android 2.2.
My testing was to use webview api,webview.loadUrl(url);
If url is from any public domain, ex, www.google.com, the web content is rendered very well.
[url]
If url is from local host, ex, tomcat with port 8080, the web content is rendered as well.
[url]
But if url is from other port, ex, websphere with port 9080, the web content is not rendered.
[url]
There is no exception thrown, and it shows blank on the emulator.
Is there any setting needed for different port?
View 2 Replies
View Related
Sep 13, 2010
I used webview to visit https link. the page always show blank. i found the way to dill with it
CODE:................
That's work fine.
But i used API Android 2.1, the above method is belongs to Android 2.2.
View 1 Replies
View Related
Sep 22, 2010
I listen to podcasts and recorded shows that can go on for several hours. I'm looking for a media player with a "skip to" function, so if I get interrupted, I don't have to fiddle with my finger on a slider to find the right section. I just enter "1:33" or whatever and the player goes to that location. Neither the stock media player nor mixzing support that (that I can see). I don't need full RSS support, automatic downloading, I just want a media player that I can skip to a particular spot in a track by specifying the time.
View 8 Replies
View Related
Aug 28, 2010
I am implementing a context menu for my main activity.
I have some XML to define the items:
CODE:...............
I have this code to create the menu:
CODE:.................
When I click the menu button, my context menu appears with the appropriate items and icons. When I select a menu item, I don't get the callback.
View 1 Replies
View Related
Jul 6, 2010
I'm having trouble getting the GPS's onLocationChanged to run on a different thread. I understand how to manage UI thread when I'm calling a function but with the GPS, I don't actively call the function.
My intent is to have a light flash every time the GPS receives a reading. I have put this function in a Runnable. I passed this function to a class that implements LocationListener. Then in the main class, I started a new thread that calls requestLocationUpdates. I was hoping that onLocationChanged of the LocationListener would run in a different thread, post to the callback and make the necessary UI effects in the UI thread. Unfortunately, the program crashes every time it tries to call requestLocationUpdates. What's the proper way of doing it?
Right now it looks something like this
Main class:
CODE:................
LocationListener class:
CODE:...............
The exception says Can't create handler inside thread that has not called Looper.prepare()
View 3 Replies
View Related
Aug 31, 2010
I have been watching the Google I/O presentation by Virgil Dobjanschi on the correct way to implement REST on Android with services and content providers. http://code.google.com/events/io/2010/sessions/developing-RESTful-android-apps.html
Based on the video I'm doing things the wrong way, which is not surprising given how hard the right way is. Anyway, having been shown the promised land in the video I'm having a bit of a problem figuring out how to get there.
I have most of it nailed but the one thing that's defeating me is the Binder Callback that Virgil references in the slides (see link above), on page 43 it shows step 2 as starting the service with startService( intent ) and step 10 as returning status information using a Binder Callback. There is no example code anywhere in the presentation which is rather frustrating. There is talk of open sourcing the Twitter client which apparently uses this approach but nothing yet and the announcement was in April.
In the video he states: "What is a binder callback? A binder callback, think of it as an interface that was passed in the request intent."
I have searched all over the place but have not been able to find any doc or examples that show how to pass a callback as part of an intent. Nor can I figure out any other way of passing in a callback.
I thought he may be referring to binding to the service and implementing the callback that way. However, he is specifically referring to a local service and using strarSerice() and not bindService(). Also with bindService() the service will be destroyed if the activity is destroyed which defeats the idea. The workaround is to use startService() and then bindService() and leave the service running for the duration. The other problem with bindService() is that the callback can not be use until onServiceConnected() completes which complicates the code even further as the action instructions can not be passed in the intent because the return callback may not be in place in time to return the results.
View 1 Replies
View Related
Jan 13, 2010
Our application will expose a Service that can be called by Activities in other people's applications.In many cases, the parent applications calling Activity may be paused before our Service completes. I am looking for the best way for a Service to communicate back to the calling Activity that may have been paused.These are the known options:
(1) Require calling Activities to have a registerReceiver() with a custom action and broadcast to that from our Service. The only way to secure this registerReceiver() is with a signature-based permission.As our Service communicates with any number of unknown 3rd party apps,we can't sign our Service's parent app with all these unknown certificates. These apps would therefore be exposing an unsecured registerReceiver() on their Activity. Would ideally like to avoid requiring this.
(2) Create a PendingIntent to send results back to the activity and give it to our Service. Our Service would send data to calling Activity's onActivityResult(). Each time the result is delivered, the calling Activity will go through onPause() and onResume() but this should be OK.
(3) The calling Activities could create a Handler. The Activity would then create a Messenger pointing to that Handler and send it to our service. Our Service can then use the Messenger to deliver our message back to the calling Activity.
View 2 Replies
View Related
Sep 13, 2010
In Java, is it possible to associate some object (i.e. a String) with a function to be called ? I have two similar menus and both have a onClickListener with some code like this: Code...
View 4 Replies
View Related
Apr 2, 2010
in android application development, i frequently go through the word "CALLBACK" in many places. i want to know want it means to tell us technically. and how i can manage the callback of the applications.
View 2 Replies
View Related
Dec 31, 2009
Could someone please shed the light as to where onItemClick() function gets called as callback when I click on the item of a ListView?
In core/java/android/widget/AdapterView.java:
onItemClick() belongs to the interface OnItemClickListener of AdapterView.
The listener is set through setOnItemClickListener() of AdapterView.
The listener is only invoked in performItemClick() of AdapterView.
The listener is also invoked indirectly in performItemClick() of ListView.
But, I still don't know where exactly onItemClick() of the listener will get called when I click on the item of a ListView. Logically it should be like:
device -> kernel driver -> dalvik VM -> my app.
Could someone please tell me the exact code that calls onItemClick() when I click on the item through the device?
In this digital era, where computing technology is pervasive, your freedom depends on the software controlling those computing devices.
Join free software movement today! It is free as in freedom, not as in free beer!
Join: http://www.fsf.org/jf?referrer=4445
View 5 Replies
View Related
Nov 10, 2010
I am working on an application in Android and I have to manipulate the data coming from the preview.
I read that the default frame rate is 15fps. I measured the time from one call of the onPreviewFrame function and the next one and I noticed that I got different times depending on the size of the preview (at the moment no other operations are done in this function). How can it be possible? I thought it would be called at any frame so 15 times in a second (approximately every 66ms) independently of the previewFrameSize.
View 2 Replies
View Related
Jun 15, 2010
I'm trying to listen for preference changes from an activity (see below). It never fires. Is it due to the fact that the activity in question is not in focus when the change event fires?
CODE:.....................
View 10 Replies
View Related
Jun 3, 2009
Hi, One of my ListView's has a CheckBox on every item's RelativeLayout.
I just found that clicking on any item of the ListView does not callback its OnItemClick().
If I remove the CheckBox from item layout, callback is ok then.
My app needs to get both callbacks from the CheckBox as well as from "the other area" of a ListView item.
I read http://android-developers.blogspot.com/2008/12/touch-mode.html But I'm a bit confuse.
How I get the callback on the ListView with CheckBox?
CODE:..................
View 7 Replies
View Related
May 4, 2010
I'm trying to create a simple multiplayer game. There's a WorkerService which is supposed to handle all network communication and all interaction between this service and my Activities is done with AIDL. I think this is a standard approach - to enable two way interaction I use also an IWorkerCallback interface (also AIDL).
The problem is that callbacks have to change things in UI which may be done only in UI thread. I've created a Handler (in UI thread) and believed that this is an obvious solution. But, surprisingly, it's not working.
My LoungeActivity calls startServer() method of IWorker interface. Corresponding method of my WorkerService does some job and makes a callback - this works fine. Then WorkerService spawns a new thread and callback from this thread results in a bad Exception being thrown:
Can't create handler inside thread that has not called Looper.prepare()
Here's some code to make it clear:
CODE:............
ServerThread code:
CODE:................
Every method from callback looks like that:
CODE:.................
In Handler's handleMessage() method I'm doing a simple switch(msg.what) and in every case there's a simple UI modification (showing a Toast, changing Text, etc.)
I have no idea why is this Exception thrown.. I've managed to fix it by packing code into a Runnable and calling runOnUiThread() but it still makes me curious - shouldn't a Handler always run in thread that created it?
View 2 Replies
View Related
Jul 29, 2010
I have an object that is used for calling callback functions ----- static jobject o;
I have assigned the callback function to that object through a pointer, env -----
o=env->NewGlobalRef(callback);
The same pointer, env, points towards the function CallVoidMethod( ) that uses JNI to reach to the java code.
env->CallVoidMethod(o, methodId, pDeviceId, deviceStatus, statusReason, connectionProgressInfo);
However on calling this function, the system is getting crashed, and VM says that it's an invalid reference to static jobject o and then it crashes.
My code is as follows :
CODE:..........................
View 2 Replies
View Related
Jul 30, 2010
I am making twitter application in which i open browser for user authentication and i pass call_back URL when launching authentication browser.
Problem is after authenticating it is calling again oncreate of TWitterShare class instead calling onNewIntent method, why is that ? my another class working fine i am unable to find difference any idea by looking at the following ocde why it is calling oncreate again ?
CODE:...................
View 2 Replies
View Related
Mar 5, 2010
I was trying to find out were my apps memory was being leaked and was able to discover that when calling registerCallback(...) it would lead to a memory leak after a screen orientation change. What could be some possible things that are causing the leak? I've tried many things. And I do have a unregisterCallback(..) call.
View 20 Replies
View Related
Sep 14, 2009
My activity calls a browser activity where the users submits their info to retrieve a PIN. That PIN is then sent as a parameter to a url specified in the request.
View 4 Replies
View Related