Steve Benett
Steve Benett

Reputation: 12933

How to get class name of the Activity which is bound to a Service?

I would like to get the class name (*.class) of an Activity which is bound to my local Service. Is there any native method which i could use to achieve this?

I tried to get that information out of the Intent I use to bind to the Service. But it seems there is no function in Intents for this.

If I wasn't blind, additionally I would like to know why there's no information about the calling Activity in an Intent?

Upvotes: 3

Views: 1400

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007266

Is there any native method which i could use to achieve this?

No, in large part because the class in question may not exist in your app, and may not even be a class.

You are welcome to package whatever identifying information you would like in the Intent, such as via an extra.

Also, if you are allowing third parties to bind to this service, you can use methods like getCallingUid() on your Binder to find out information regarding the process that bound to you.

additionally I would like to know why there's no information about the calling Activity in an Intent?

Because there is not necessarily a calling Activity. The binding engine works with C; C does not have classes, let alone activities.

Upvotes: 4

Related Questions