[android-developers] modify active intentfilter

2009-10-20 Thread Bart van Wissen

Let's say that I have a BroadcastReceiver that has already been
registered, and I want to change its IntentFilter at that moment (add
a new data authority for example). Is this at all possible?
Or do I have to unregister it first, and then re-register it with the
updated IntentFilter?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] detecting shake movement without draining the battery

2009-09-10 Thread Bart van Wissen

I would like to detect shake movement in a service that is running in
the background, even when the phone is not currently being used.
Is it true that the only way to do this is to hold a wake lock? I
suppose this would consume a lot of energy and drain the battery very
fast.

Is there no way to wake up the phone whenever a shake movement occurs?
Maybe with the native sdk? I would imagine the accelerometer causing
some kind of interrupt.

Any ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] running emulator on a remote machine

2009-09-08 Thread Bart van Wissen

Is there any way to connect the debugger to an emulator running on a
remote machine?
It's using TCP so I suppose it shouldn't be too difficult, but I can't
figure out how.

I would like to run the emulator on my (fast) laptop and do my coding
on my (slow, but with bigger screen) desktop machine.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: running emulator on a remote machine

2009-09-08 Thread Bart van Wissen

I'm sorry, I don't understand.
I would like the emulator running on the laptop to show up in the list
of devices in DDMS on my desktop, and receive its logcat output, etc.
How could I use NFS for that?

On 9 sep, 01:01, Roman ( T-Mobile USA) roman.baumgaert...@t-
mobile.com wrote:
 If your systems support NFS then start the emulator remotely over NFS.

 --
 Roman Baumgaertner
 Sr. SW Engineer-OSDC
 ·T· · ·Mobile· stick together
 The views, opinions and statements in this email are those of the
 author solely in their individual capacity, and do not necessarily
 represent those of T-Mobile USA, Inc.

 On Sep 8, 2:38 pm, Bart van Wissen bartvanwis...@gmail.com wrote:

  Is there any way to connect the debugger to an emulator running on a
  remote machine?
  It's using TCP so I suppose it shouldn't be too difficult, but I can't
  figure out how.

  I would like to run the emulator on my (fast) laptop and do my coding
  on my (slow, but with bigger screen) desktop machine.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-09-01 Thread Bart van Wissen


On 1 sep, 10:01, guruk ilovesi...@gmail.com wrote:
 thanks for all comments.
 does anyone have a simple source demo.
 I could try that
 buffer[i] = (short) ( Math.sin((2. * Math.PI * i * f) / samplerate) *
 Short.MAX_VALUE )
 ... and what afterwards, how to play it?

 I am just wondering ( please i am a total newbie in sound)
 when I fill always a buffer like above... how long is that sound??

That depends on how many samples you write. The AudioTrack object
plays samples at a certain rate, for example 22050 Hz. To create a 1
second tone, you would thus have to write 22050 samples.

I am not familiar with android's AudioTrack interface, but I'm sure
the reference manual will help you there. I suppose when you call play
() it will start playing as soon as you write enough data to it with
write(). So you can generate the tone while it's playing.

It's not a completely trivial subject as you have to get into how
digital audio actually works, so if you're completely new to that you
might want to try to find some kind of library to help you out.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Constructor problem

2009-08-31 Thread Bart van Wissen

The problem is that renvoi_liste_recette_xml() throws an Exception
(you shouldn't do this - either make it more specific or catch the
exception within the method) and the initialization section of your
Activity cannot handle this, because the constructor of Activity
doesn't throw Exception.

Move the initialization of your member variables to (a try/catch block
within) the onCreate callback.


On 31 aug, 15:07, sweet junkybr...@gmail.com wrote:
 Eclipse say that for the line:
 ArrayList listeRecette = renvoi_liste_recette_xml();
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-08-31 Thread Bart van Wissen

You will have to create the wave data yourself using a sine-function.
Fill a buffer of shorts (for 16 bit audio) with something like this:

buffer[i] = (short) (Math.sin(((double) i / samplerate) * f) *
Short.MAX_VALUE);

(please correct me if I'm wrong)

If you need a 5 seconds tone, I suppose you could just fill a buffer
of size 5 * samplerate, but you could also try something smart with a
loop and repeatedly feed the same buffer to the AudioTrack object.
Just be aware of rounding errors and aliasing.



On 31 aug, 20:28, Eduardo Aquiles dudu...@gmail.com wrote:
 You could use AudioTrack. But you will need to create the data to send
 to it.

 On Aug 31, 2:19 pm, guruk ilovesi...@gmail.com wrote:

  sorry i just dont find that simple thing.
  how to create a tone lets say 10khz / 5 secs

  something like that,, just play a individual created sound, not
  playing a mpg or so?

  any example will be helpful

  thx
  chri


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: how to make sound hz?

2009-08-31 Thread Bart van Wissen

I'm sorry, the formula is wrong.
I think it's

buffer[i] = (short) ( Math.sin((2. * Math.PI * i * f) / samplerate) *
Short.MAX_VALUE )

But I'm not sure. I guess 3 AM is not the time to think about this.
Anyway it should give you an idea of how to do it.

On 1 sep, 02:23, Bart van Wissen bartvanwis...@gmail.com wrote:
 You will have to create the wave data yourself using a sine-function.
 Fill a buffer of shorts (for 16 bit audio) with something like this:

 buffer[i] = (short) (Math.sin(((double) i / samplerate) * f) *
 Short.MAX_VALUE);

 (please correct me if I'm wrong)

 If you need a 5 seconds tone, I suppose you could just fill a buffer
 of size 5 * samplerate, but you could also try something smart with a
 loop and repeatedly feed the same buffer to the AudioTrack object.
 Just be aware of rounding errors and aliasing.

 On 31 aug, 20:28, Eduardo Aquiles dudu...@gmail.com wrote:

  You could use AudioTrack. But you will need to create the data to send
  to it.

  On Aug 31, 2:19 pm, guruk ilovesi...@gmail.com wrote:

   sorry i just dont find that simple thing.
   how to create a tone lets say 10khz / 5 secs

   something like that,, just play a individual created sound, not
   playing a mpg or so?

   any example will be helpful

   thx
   chri


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Parcel/unparcel Bundle classloader bug?

2009-08-10 Thread Bart van Wissen

I have a parcelable class whose writeToParcel() method puts some data
in a Bundle and writes it to the parcel.
This parcel gets sent from a client process to a service process.

At the side of the service, the readFromparcel() method tries to read
this Bundle from the parcel. A strange thing happens here.

First of all, I got a ClassNotFoundException for one of the objects
inside the Bundle. I fixed this by using readBundle(this.getClass
().getClassloader()) to force it to use the application's
classloader.

After this, I no longer got the ClassNotFoundException, but I did get
a different bundle, containing only the following entry:
mParcelledData.dataSize=376

This is not what's supposed to be in the bundle.

In the sourcecode Parcel.java I see this, in the readBundle
(Classloader) method:

final Bundle bundle = new Bundle(this, length);
if (loader != null) {
  bundle.setClassLoader(loader);
}


So the classloader is set after reading the bundle, instead of before.
Shouldn't that be the other way around?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Parcel/unparcel Bundle classloader bug?

2009-08-10 Thread Bart van Wissen

I noticed that the mParcelledData thing was the result of
Bundle.toString() when the Bundle hasn't been unparcelled yet, so I
decided to stick in a bundle.containsKey(something) before I printed
the toString to force it to unparcel first, but then I got a
NullPointerException. And I did check if bundle was not null.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] referencing projects in eclipse

2009-07-27 Thread Bart van Wissen

I'm working on two projects. One is essentially a library, and the
other is an application using that library.
Now from the application project, I want to use the library's classes,
so I added that project to the required projects under java build
path.
It seems to compile fine, but at runtime, I get this error:

07-27 11:26:57.037: ERROR/dalvikvm(741): Could not find class
'interdroid.contextframework.ContextManager', referenced from method
com.bartvanwissen.contextframeworktest.MainActivity.onCreate

Apparently, the library project's classes are not added to the apk
file. How can I make sure they are included? Is this at all possible?

Since I'm working on both projects at the same time, I would like to
prevent having to create a jar file every time I want to test
something.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] sending / receiving custom broadcast intent

2009-07-25 Thread Bart van Wissen

I'm building a service that sends a broadcast intent when some value
changes.
The service sends the broadcast like this:

Intent broadcastIntent = new Intent();
broadcastIntent.setAction(nl.vu.contextframework.NEWREADING);
broadcastIntent.setData(Uri.parse(context://+cer.getKey()));
broadcastIntent.putExtra(reading,cer);
broadcastIntent.addCategory(nl.vu.contextframework.CONTEXT);
sendBroadcast(broadcastIntent);


In some Activity (in a different process), I'm tryint to receive this
broadcast as follows:


IntentFilter intentFilter = new IntentFilter();
intentFilter.addDataScheme(context);
intentFilter.addCategory(CATEGORY_CONTEXT);

registerReceiver(new BroadcastReceiver() {
  public void onReceive(Context context, Intent intent) {
Log.d(TAG,Received intent +intent);
  }
}, intentFilter);


The intent is never received though. What am I doing wrong? Does my
intentfilter not match the intent?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: sending / receiving custom broadcast intent

2009-07-25 Thread Bart van Wissen

On 25 jul, 14:00, Mark Murphy mmur...@commonsware.com wrote:
  Could it be that I'm using a non-existent scheme?
  I invented context:// myself, maybe this is not a good idea?

 In theory that should work, though I haven't tried it myself.

 I take an Occam's Razor approach to intents and filters: they should be as
 simple as possible, but no simpler.

 In your case, unless you are creating a content provider, I don't know the
 value of your inventing schemes and using setData(). Just put the values
 you need in the extras and filter on your action.


I'm using the data because it allows me to receive only updates to
specific keys by including them in the IntentFilter. Many of these
intents may be fired and different applications may want to filter
most of them out.

Anyway, just to see if it helps, I tried not using the data and
putting everything in the extras:

Intent broadcastIntent = new Intent();
broadcastIntent.setAction(nl.vu.contextframework.NEWREADING);
broadcastIntent.putExtra(reading,cer);
broadcastIntent.putExtra(key, cer.getKey());
broadcastIntent.addCategory(nl.vu.contextframework.CONTEXT);
sendBroadcast(broadcastIntent);


and in the activity:

IntentFilter intentFilter = new IntentFilter();
intentFilter.addCategory(CATEGORY_CONTEXT);
registerReceiver(new BroadcastReceiver() {
  public void onReceive(Context context, Intent intent) {
Log.d(TAG,Received intent +intent);
  }
}, intentFilter);


But I'm still not receiving anything.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Location updates not coming through

2009-07-22 Thread Bart van Wissen

I'm writing a program that uses a LocationListener to listen for
location updates.
I'm playing a GPX file that I recorded, which contains a route. I know
for sure that this file is correct.
My program seems to only receive 1 location update, and then nothing.
I have both minimum time and distance set to 0.
I thought it may be a bug in my own program, so I decided to test the
same GPX file with google maps. In google maps, I don't see 'my
location'  moving. However, when I switch to the home screen and back,
my location is updated.
It seems that the last known location is fetched correctly, but
realtime updates are not coming through.

Is this a known problem?

I'm working on a Windows Vista 32 bit system with Android SDK 1.5 r3
My number format settings are set to English. (I know this is required
to send mock locations from DDMS).


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Tree of parcelables: Class not found when unmarshalling

2009-07-21 Thread Bart van Wissen

So should I submit this as a bug?


On 20 jul, 13:07, Bart van Wissen bartvanwis...@gmail.com wrote:
 I'm using a tree structure in my application, which has to be passed
 to a service. All nodes in the tree are of the type ExpressionTree,
 which is an interface.
 All nodes are also Parcelable.

 Now in my setup I have these types (all implement ExpressionTree and
 Parcelable):
 - ExpressionTreeRoot, a class with a reference to an ExpressionTree.
 - AndTree, a class with two ExpressionTree references.
 - StringCondition, a leafnode in the tree

 Now I'm passing a tree with an ExpressionTreeRoot referencing an
 AndTree referencing two StringConditions to a service, running in
 another process.

 ExpressionTreeRoot - AndTree - 2 StringConditions
 The parcel that is sent to the service is thus a flattened version of
 this tree, containing 3 parcels.

 When unmarshalling, the service process throws a
 ClassNotFoundException:

 07-20 10:44:16.431: ERROR/Parcel(1355): Class not found when
 unmarshalling: nl.vu.contextframework.conditions.AndTree, e:
 java.lang.ClassNotFoundException:
 nl.vu.contextframework.conditions.AndTree

 I can see in my log output that ExpressionTreeRoot.readFromParcel() is
 called, which in its turn calls parcel.readFromParcel to read the
 included parcel, which is in this case a parceled AndTree. This is
 where the ClassNotFoundException is thrown.
 The parcel seems to be reading the class type correctly from the
 parcel,  otherwise it wouldn't be printing the name
 nl.vu.contextframework.conditions.AndTree. But somehow it is unable
 to find this class, even though I'm sure it exists.

 Can anyone tell me what's going on, or give me some tips on how to
 investigate further?
 I'm using the default classloader by the way.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Tree of parcelables: Class not found when unmarshalling

2009-07-21 Thread Bart van Wissen

On 21 jul, 11:13, Dianne Hackborn hack...@android.com wrote:
 There isn't enough information here to know if it is a bug in the
 platform...  off-hand, I would guess not, since most of the logic in
 marshalling/unmarshalling such things needs to be written by the developer
 and doesn't come from the platform.  Plus there isn't a
 Parcel.readFromParcel() method so it is even harder to tell...  if this is
 actually Parcel.readParcelable(), you need to make sure you are using the
 class loader for -your- app, which is the one that knows about your class
 loader.  The system class loader only knows about the core framework
 classes.

Thank you.
Yes, I meant readParcelable(), sorry about that.
I guess I need to pass the right classloader then. I thought that
'default' meant the classloader for my app.



 That all side, a possibly larger question is...  do you need to do this at
 all?  If the service is not explicitly running in its own process but just
 in the normal same process as the rest of the app, there is no reason to use
 aidl at all.  If it has been set up to run in another process, is there
 really a good reason to do this instead of just using the much simpler (and
 usually more efficient) approach of running locally?



It's necessary, because it is a service that communicates with a
number of applications simultaneously.
Also note that passing this tree is not something that needs to be
done a lot of times, usually just once for an application, so it's not
really an issue if it's an expensive operation.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Tree of parcelables: Class not found when unmarshalling

2009-07-21 Thread Bart van Wissen

Alright, I fixed it by changing

tree = parcel.readParcelable(null);

into

tree = parcel.readParcelable(getClass().getClassLoader());

Thanks again.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: extending parcelables

2009-07-17 Thread Bart van Wissen

On Jul 16, 6:52 pm, Dianne Hackborn hack...@android.com wrote:
 Just use ArrayListParcelable as your data type.


Putting ListParcelable in my aidl file resulted in the following
errors:

The method writeBinderList(ListIBinder) in the type Parcel is not
applicable for the arguments (ListParcelable)
for this line in the automatically generated Proxy:
_data.writeBinderList(conditionList);

Type mismatch: cannot convert from ArrayListIBinder to
ListParcelable
for this line:
_arg0 = data.createBinderArrayList();
in the onTransact method of the Stub

Apparently the AIDL compiler thinks a ListParcelable is a
ListIBinder?

I ended up just making it a List with no type at all, and verifying
the type in the service implementation. This works for me.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: extending parcelables

2009-07-16 Thread Bart van Wissen

 2. Use a generic Parcelable class type, in which case the marshalling code
 will inspect the class type, included that in the marshalled data, and use
 that to re-construct it on the other side.


I don't understand this.

My program deals with Condition objects, which can be put in a list to
specify a series of search conditions. There are specific classes like
StringCondition, TimeCondition, LocationCondition, etc. They are all
subclasses of Condition, but they all have their specific sets of
fields.

A list of those has to be passed to a service. Now how would I use a
generic Parcelable class for this? To be honest I don't have much
experience with generic classes.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: extending parcelables

2009-07-15 Thread Bart van Wissen

On Jul 15, 5:21 pm, Streets Of Boston flyingdutc...@gmail.com wrote:
 It looks like your Animal class is abstract and should never be
 constructed. Declare Animal 'abstract' and see if you get an
 instantiation error.

It should be abstract, but I cannot make it abstract because then I
cannot add the CREATOR to it, which is needed to implement
Parcelable.
So now it is just an empty superclass.



 Have your tried to put the 'public static final Parcelable.Creator
 CREATORCat' and 'public static final Parcelable.Creator
 CREATORDog' variables and definitions in both Cat and Dog (and not
 in Animal)? This will make sure that the factory-method
 createFromParcel creates the appropriate subclass (Cat or Dog, and not
 Animal).

I did that, but it doesn't work. Those CREATORs are never actually
called.
The AIDL compiler sees the ListAnimal and assumes that every element
in the list is an Animal, and no subclass of it, and it creates the
unmarshalling code accordingly.


 About the readFromParcel().
 If Cat and Dog both implement readFromParcel() it should work fine.
 Are you sure that the variable 'a' is not an Animal instance?


That was my mistake, I didn't properly override the method (one was
private and the other was public). I deleted my post when I noticed
this. Unfortunately this was while you were typing your reply.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Documentation inconsistency in Service.onBind() intent extras availability

2009-07-02 Thread Bart van Wissen

Is the MyPool object actually passed by reference here, from the
service to the client?
So changes to the object are reflected at the service side and at any
clients that may share the same reference?

On 2 jul, 11:15, Dianne Hackborn hack...@android.com wrote:
 No, have a method on the top-level interface that returns another
 object/interface based on whatever parameters you give it:

 interface MyPool {
   void doSomething();

 }

 interface MyService {
   MyPool getPool(int sel1, String sel2);

 }

 If needed you can have a release() method on MyPool for the client to
 indicate when they are done with it.



 On Wed, Jul 1, 2009 at 11:45 PM, Gert gsch...@gmail.com wrote:

  That would mean prefixing all the methods with their dynamic
  identifiers to select the correct serivice object, such as:
   void myPoolMethod(poolId, real parameters)
   void myCollabMethod(poolId, collabId, real parameters);
  and then looking up the specific instance with a global lock in some
  form of registry. The poolId and collabId need to be unique over
  (undesired) service destruction, which means lookups of strings in
  hashtables...
   getOrCreatePool(poolid).getOrCreate(collabId).myMethod(...);
  Do you know how expensive is it to keep another connection object
  around (well, setting it up most likely) versus 1-2 hashtable lookups
  in every RPC call?

  I chose this design since the expectation is 0-1 bindings to a single
  pool and, depending on the activity, one-few bindings to one of those
  collaboration objects per activity. You could compare the basic
  structure to the more traditional content (provider) based apps that
  work with a list of items (pool), and specific item (collab
  thing). Not all activities will need a binding to the pool, or more
  then one collab object.

  Also, if you bind to a binder linked to a specific pool/collabobject,
  you can do easy refcounting allowing for dynamic destruction of the
  server object trees, else I think you'll have to force the client app
  to not only unbind the service, but also remove their references. This
  might not be an real point though, just more bookkeeping.

  On Jul 2, 1:11 am, Dianne Hackborn hack...@android.com wrote:
   You may want to seriously consider just having a single service and
  Binder
   interface, with calls on to that top-level binder interface to get the
   secondary interface(s) the client wants.  In general I find this cleaner
   than setting things up where there are an unbounded number of Intent
  objects
   you can bind to (keep in mind that the activity manager needs to set up
  and
   hold a new kind of connection object for each of these), or ending up
  with
   multiple service components.

   Once you have a binder interface, you have a mechanism for very rich
   interaction between the service and client through whatever API you want
  to
   describe in aidl.

   On Wed, Jul 1, 2009 at 3:56 PM, Gert gsch...@gmail.com wrote:

For completeness, I ended up going this:

My service is maintaining (dynamic) pools of (dynamic) collaberation
objects, so I ended up with 2 services:
MyPoolService, bound with:
 action=package.IMyPoolSerivice
 data=package:poolname
and MyCollaberationService, bound with:
 action=package.IMyCollaberationService
 data=package:poolname#id

This way I return a binder per pool, and a binder per pool-
collaberation pair, and I can keep (and dynamically create) the state,
in the binders. Perhaps using the data Uri to select a specific
(binder) instance isn't the way this is intended, but it does map well
to this service operates on that data.

Regards,
 Gert Scholten

On Jul 1, 11:57 pm, Dianne Hackborn hack...@android.com wrote:
 Good point, you can make up whatever action string you want (provided
  it
has
 your appropriate namespace); it is a convenient convention for this
  to be
 the fully qualified name of the interface that is being requested.

 On Wed, Jul 1, 2009 at 1:42 PM, Bart van Wissen 
  bartvanwis...@gmail.com
wrote:

  I think you can actually use the Intent's action to select the
  implementation stub that you need. In the examples, the class name
  is
  used, but I think you can use anything you want, as long as you
  create
  the appropriate intent filter for the service.

  On 1 jul, 20:33, Gert gsch...@gmail.com wrote:
   I have a service working with selectable backends internally, and
  the
   user is able to select which on to bind to. I was hoping to
  optimize
a
   bit by have that selection made by the bindService call, and just
keep
   a single Binder per backend implementation. Guess I'll just
  create a
   new Binder per bindService, and point it to the backend to use.

   Anyway, thanks for the information - following the the
  documentation
   it is :)

   Regards,
     Gert Scholten

   On Jul 1, 6:24 pm, Dianne

[android-developers] Re: Documentation inconsistency in Service.onBind() intent extras availability

2009-07-01 Thread Bart van Wissen

I think you can actually use the Intent's action to select the
implementation stub that you need. In the examples, the class name is
used, but I think you can use anything you want, as long as you create
the appropriate intent filter for the service.


On 1 jul, 20:33, Gert gsch...@gmail.com wrote:
 I have a service working with selectable backends internally, and the
 user is able to select which on to bind to. I was hoping to optimize a
 bit by have that selection made by the bindService call, and just keep
 a single Binder per backend implementation. Guess I'll just create a
 new Binder per bindService, and point it to the backend to use.

 Anyway, thanks for the information - following the the documentation
 it is :)

 Regards,
   Gert Scholten

 On Jul 1, 6:24 pm, Dianne Hackborn hack...@android.com wrote:

  Yeah that is a little wrong...  the extras are very complicated, because the
  bind is cached in various places.  So you will see the extras for -some-
  request to bind, but not necessarily the current one.

  I would strongly strongly strongly urge against using extras here.  There
  really is no need at all -- you will be getting back a full IPC interface to
  the object, through which you can do whatever interaction and data passing
  you want.  The Intent in this API is intended -only- to identify which
  interface you are interested in.  (I think I had intended the code to strip
  out the extras because of how undefined it is about what you will get, but
  apparently had forgotten to do that.)

  On Tue, Jun 30, 2009 at 11:25 AM, Gert gsch...@gmail.com wrote:

   Hi,

   I have a question about the availability of the extras in an intent
   passed to Service.onBind(). The documentation at

  http://developer.android.com/reference/android/app/Service.html#onBin...)http://developer.android.com/reference/android/app/Service.html#onBin...
   specifically states Note that any extras that were included with the
   Intent at that point will not be seen here.. However, extras are
   available (emulator, SDK 1.5).

   Is the documentation off/outdated and are the extras available
   intentionally, or are they unintentionally exposed to the onBind
   method? Can we rely on extras remaining available at this point?

   Regards,
    Gert

  --
  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.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Expression Evaluation library that works in Dalvik

2009-05-26 Thread Bart van Wissen

I'm looking for a library that will let me evaluate expressions at
runtime. Required:

- basic logical expressions (AND, OR, NOT operators)
- custom functions
- some mechanism to resolve variables (I want to link some variables
to some entities in a ContentProvider)

I have tried a number of libraries including MVEL and Juel, which
would be perfect but they do not seem to work under Dalvik. I couldn't
really figure out why, but it looks like they rely on some class
loading mechanism which seems to be problematic in Dalvik. There was
also some problem with libraries checking the java runtime version
(System.getProperty(java.version)) which is 0 in Dalvik for some
unknown reason.

I have also looked at BeanShell, but I think this is not really
suitable because it is a full blown scripting engine (which leads to
some security issues in this case) and all I need is evaluation of
simple expressions.

Any suggestions?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---