user3782810
user3782810

Reputation: 113

How access global static variable from other process

I am developing an application where my application is running com.application process and My service is running com.applicion.service process (declered in manifest file) .

But I have a public static boolean variable in com.applicion.servic process and want to access it value updated on com.application.

Is there any way to do it ..

Please help me on this.

Upvotes: 2

Views: 592

Answers (3)

Fahad Alkamli
Fahad Alkamli

Reputation: 138

I just had the same problem my Service was running on a different process and I can't seem to get the static variable that belongs to the Service in my activity. After making the Service and the activity run on the same process I could get the static variable> so in the end please be aware that different process don't seem to have access to static variables> Hope this helps someone>

Upvotes: 1

Techfist
Techfist

Reputation: 4344

Is they both are under one application, why dont you access it via CLASS_NAME.STATIC_VARIABLE_NAME,

if they are process which belong to two different application, then AIDL/Messanger or binders are the only option you have to do the same.

Upvotes: 1

Sitram
Sitram

Reputation: 1432

I store global available information in a singleton class. Whenever I update the variable in an activity I also write it into my singleton class.

This way I can access it from anywhere I like.

Upvotes: 0

Related Questions