Android :: What Is A Binder Callback

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.

Android :: What is a binder callback


Android :: Dialog Callback From Withing Callback?

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

Android :: JavaBinder - FAILED BINDER TRANSACTION

Jan 4, 2010

I currently have a lot of problems with this error. I programmed a widget and a service that runs in the background. This service is updating the widget on different occasions (position changed, screen turned on, timer based...) with images and text it's loading from a server. After a couple of updates I always get an error from the JavaBinder, at least that's what DDMS says. Reproducing the problem with my app is quite easy but I just can't figure out what's going on there.

View 6 Replies View Related

Android :: Binder Is Leaked By Binding To A Service

Jul 30, 2010

I made a code for my understanding of Android Service class.

It has just a single Activity and Service in apk. Service is the same as the sample code of API reference as below: http://developer.android.com/intl/ja/reference/android/app/Service.ht...

A client side is an Activity based on the above sample, and just added the following code:

CODE:.......

My sample application has a check box which starts(binds)/unbind to the local service on a single process. The local service instance is created by every bind request (and destroyed by every unbind).

If I press the button repeatedly, then LocalService$LocalBinder is leaked!

The problem is not resolved even If I set an obtained binder to null (like below).

CODE:...............

View 6 Replies View Related

Android :: Adding Native Binder Service Permission Error

Sep 10, 2010

What is the best way to add a new native service that uses Binder and can get past the service_manager.cpp restrictions on what users can add services? I have created a new native service that is similar to the MediaPlayer. I make the addService() calls to add the Binder service to the system. This worked fine when the service was started as root. I moved the new service to be started as the "media" user. Then I receive permission errors because of the table in service_manager.cpp where there is a check for users and allowed Binder services. Do I have to add my service to the table or is there some other way?

View 2 Replies View Related

Android :: Main And Three Binder Threads Are Running After Application Close

May 21, 2009

My application starts a remote service and binds to it. If I close the application with the "back" button there are still some threads running (listed in the Debug View of Eclipse) - main thread, and three Binder threads. In onDestroy() I call unbindService(service_connection) - is there something else to clean up?

View 4 Replies View Related

Android :: Failed Binder Transaction When Returning Camera Image

Feb 15, 2010

I get the Failed binder transaction error in the logcat when returning the image taken with the camera from the camera intent back to the parent intent (as a byte[] using putExtra). I don't understand why, its not like its a big bitmap or anything. It only happens when i take pictures with lots of light, because then the byte[] is bigger. The error occurs when leaving the camera intent. Does anyone see a mistake in my code?

Here is the code of the camera intent:

CODE:.............

And here is the code that calls the camera intent:

CODE:..................

View 1 Replies View Related

Android :: How To Pass Complex Data Structures Between Service And Remote Binder?

Feb 17, 2010

The object passing between an Android service and the remote binder is happening through serialization of the object. If the service needs to return a very large collection, it seems very inefficient to use this. What is the recommended way to deal with this?

View 1 Replies View Related

Android :: Failed Binder Transaction When Passing Byte - From Camera - Between Intents

Feb 16, 2010

I have a problem with an app that lets the user take a picture. I've posted it on some forums already, but nobody seems to recognize the problem. Hopefully someone here knows a solution :)

I've put the code of taking a picture in a seperate activity. Then I call the camera intent from my main activity using activityForResult. In the camera intent, I use putExtra to return the camera image (as a byte[] without doing anything to it). But when the program transitions back from the camera intent to the parent intent that called it I get a Failed Binder Transaction error in the logcat because the byte[] is too big. But I don't understand this, because the image is not even taken using the maximum resolution :S

The code of my camera intent is:

CODE:......................

View 6 Replies View Related

General :: Galaxy Grand Duos - Backup Apps With Data Binder Before Flashing?

Apr 9, 2013

I have installed many applications on my Galaxy Grand duos, with binding the applications data to External SD card (32gb), what will be the best practice to backup all the application and the data before installing another firmware? I don't have enough space on internal sdcard to unbind the application data.

View 5 Replies View Related

Android :: Why Don't Get My OnContextItemSelected Callback

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

Android :: GPS Callback Off UI Thread?

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

Android :: Service Callback To Activity

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

Android :: Defining A Callback Function For A Given Value

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

Android :: Manage The Callback Of The Applications?

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

Android :: OnItemClick Gets Called As Callback?

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

Android :: Camera Callback OnPreviewFrame?

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

Android :: OnSharedPreferenceChangeListener Never Receives Callback

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

Android :: ListView OnItemClickListener No Callback

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

Android :: Callback From Another Thread Causes An Exception

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

Android :: Invalid Reference During Callback?

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

Android :: Callback URL Calling Oncreate

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

Android :: Register Callback Leaks Memory?

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

Android :: How To Capture Browser Activity Or Callback

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

Android :: Starting An Activity From Callback Class

Aug 18, 2010

I have an activity class(Application Class ) which calls a service class(Service Class) and closes. The service class takes about 5 seconds to complete its task and calls a method which is present in another class(Callback Class). Now according to the result, the callback needs to notify the Application class.Once i get the callback from the service, I tried calling a method defined in the Application class. In this method i create a new intent of Application class and call startActivity(Application Class). But this is not working. Can anyone tell where i am going wrong and what can I do to solve this issue.

View 5 Replies View Related

Android :: Callback To Activity After Layout Has Completed?

Jun 3, 2009

I want to find the dimensions of the various views in my layout. My understanding is this can only be done after layout is completed since layout is somewhat dynamic. So, after the activity calls setContentView() and then returns control on the main thread to the OS so that layout can occur, how do I get a notification that layout has completed so I that I can query the views for their dimensions? On a related topic, can I find out the status bar's height or least the screen's full size (from which the status bar's height can be calculate by subtracting my window's height)?

View 2 Replies View Related

Android :: Network Service Need To Return Callback

Oct 6, 2010

if the service dies, and i know it can during request processing, it's an issue for me, first i've seen it, the process wont die until the net request returns (then the thread dies gracefully), unless kill -9 is used on the process... then i'm not sure what android does with the connections. I'm not sure what's the approach i should take here.(it will be true though even if this was a local thread and not a service)if i want the service to listen on a callback and call it once the network processing is done, i'm in a problem, no instances can be passed on using Intents.

So i need some other solutions, all the ones i though of sounds bad to me: A. use IBinder to get instance of the network service class then i can call one of it's methods and pass on an instance, this will work since they all run in the same process, BUT requires me to use Async way to get a Network instance which is not so suitable for me. B. Use static member in the Service i can access, then what to i need the service for ?. use intent to send parameters only to the service, the service will compose a Request out of it and put it in the queue, then once done will send a response using intent which will encapsulate the response (which might be long!) and will also contain the name of the calling class as a string so all the Receivers will know if it's for them or not - BIG overhead of encapsulating data in Intent and search in all the receivers for the right one to get the response.I don't want to use the service as a local running simple thread since i'm afraid if i'll run it in the root activity i will have to use static container so it will be visible in each activity and if the root will be destroyed for some reason it will take all the service with it, even if i start new task and the process is still alive.Anyone got some nice ideas on how to approach this thing ?

View 1 Replies View Related

Android :: No Callback When List Item Is Touched

Feb 1, 2009

I have a ListView that is populated with a custom adapter. When an item is clicked with the trackball, it works fine, i.e. I can catch the event and move on, though when I touch an item with my finger there is no callback from the listener.The item does respond to the touch, by turning orange for that moment.What am I missing? Is there another listener I need to configure?

View 11 Replies View Related

Android :: Click Within WebView Causes Callback To Application

Feb 10, 2010

I'm thinking of implementing a HTML welcome panel to our Android app, which presents news and offers on the start-up screen. My question is now, if I present an offer to a specific place (with an id string) can I trigger a callback from the WebView (maybe via Java Script) to the Android app and passing that id string to make it start a new Activity which loads and shows data from a server (JSON) depending on that id string?

The second part is already implemented and working. My main concern is how to get the id string from the HTML WebView back to the Android app when the user clicks on it.

We prefer to use a WebView for that specific welcome panel, because it gives us more flexibility to customize by using HTML.

View 1 Replies View Related

Android :: AudioRecord Class - Callback Is Never Called

Feb 15, 2010

My Android Java Application needs to record audio data into the RAM and process it. This is why I use the class "AudioRecord" and not the "MediaRecorder" (records only to file).

Till now, I used a busy loop polling with "read()" for the audio data. this has been working so far, but it peggs the CPU too much. Between two polls, I put the thread to sleep to avoid 100% CPU usage. However, this is not really a clean solution, since the time of the sleep is not guaranteed and you must subtract a security time in order not to loose audio snippets. This is not CPU optimal. I need as many free CPU cycles as possible for a parallel running thread.

Now I implemented the recording using the "OnRecordPositionUpdateListener". This looks very promising and the right way to do it according the SDK Docs. Everything seems to work (opening the audio device, read()ing the data etc.) but the Listner is never called.

I am working with a real Device, not under the Emulator. The Recording using a Busy Loop basically works (however not satifiying). Only the Callback Listener is never called.

Here is a snippet from my Sourcecode:
CODE:.........................

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved