How to add an API to handle multi int parameters as output in BnInterface and BpInterface

by waterblood » Tue, 28 Apr 2009 07:05:27 GMT


Sponsored Links
 Hi All,

   I just want to add a simple api into current Android framework's
Interface. The API looks like as below:

  status_t getDestRect(int *left,int*right,int*top,int*bottom,int
*rot);

in which int *left,int*right,int*top,int*bottom,int *rot works as
output parameters.

I checked some implement of BpInterface, they all use
Parcel::writeStrongBinder(const sp<IBinder>& val) to pass down the
memory pointer to Binder. Is that means all input pointers should be
wrapper to a sp<IBinder>? Is it a way to simply wrapper a int *,or
some basic type pointer?


Best Regards
Guoyin Chen

--~--~---------~--~----~------------~-------~--~----~



How to add an API to handle multi int parameters as output in BnInterface and BpInterface

by Dianne Hackborn » Wed, 29 Apr 2009 04:21:36 GMT


 If you are adding this to a Binder interface, you can write it as output
parameters -- marshall the results into the reply, and unmarshall them into
the int pointers on the other side.  You can try writing an .aidl interface
with these as [out]int and look at the generated Java code to get an idea of
how you would write it.






-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Asynchronous Updates to a custom View

Hi,

I am creating a custom view to represent some kind of photo-collage.

Here's how I have intended to do / achieve...

(1) Create a custom "ViewGroup" that will comprise of only and only
ImageView views with pseudo-random size and rotation.
(2) Since images will be fetched on the fly from the server and I do
not intend to use more than a few simultaneous threads to fetch the
data from the server, I am using "Handler" to receive any responses
(3) All UI update is being done in onLayout
    3a. For the first time, I add required ImageView instances (since
I know the number of images)
    3b. All the image-view's show a "loading" image
    3c. When the response is available from server, the Handler
handles the message and sets the "ImageBitmap" to the one obtained and
decoded from the server -- whenever an image download is complete, I
call "requestLayout" to ensure that onLayout is called
    3d. Each image is encapsulated in a class with two pieces of
information - state (Loading/Loaded) and image (Bitmap)


Problem:
I see that as and when the responses are available, the onLayout is
called that sets the appropriate images to the UI.
However, I do not see "loading..." images being shown up. It seems
that the UI thread is blocked and the UI update really does not happen
immediately when the image-bitmap is set.


Questions:
1. What am I doing wrong... I think that I should not call
requestLayout multiple times but only setImageBitmap when the response
is available. Tried that too... but of no use :(
2. What's the suggested approach to implement this kind of a UI...


Thanks in advance.



Happy Hacking,
Gaurav Vaish
www.mastergaurav.com
--------------------------------------

-- 

2. java.util.Random caching?

That is the only thing I can think of.
When I generate a random number (for the radius of a ball), after a
while, the radius goes to one number and sticks that way.
I've even tried setting the random number value to 0 before getting
the random number, and java.util.Random must be at fault, it still
gives the same random number.
Here is an apk if you would like to try it yourself: 
http://74.118.194.50:84/Balls.apk
Any help is appreciated

Oh, and here is a snippet of the code (I would rather not release the
full source):

<code>
Random randomizer = new Random(System.currentTimeMillis());
int hw;

hw = randomizer.nextInt(95-15+1)+15;
</code>

after that it assigns the new ball with the radius.
It's very odd that it does it after an amount of them generated, no
clue why.
Other people in IRC were perplexed by it too

-- 

3. XL tidak bisa download dari Market

4. Question regarding the database creation

5. Seven pushmail

6. Beta Test - Diddo - Discover Apps!

7. Sdcard class 6 4giga