• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Sharing two apps to share process id

emnaki

Lurker
Jul 13, 2009
4
0
As the title says I am trying to get two apps to share process ids. Below are the two manifest files for the two applications:

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.testapp"
      android:versionCode="1"
      android:versionName="1.0" android:sharedUserId="@string/myTestSharedUser">
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:process="@string/automprocess">
        <activity android:name=".testapp"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>            
        </activity>
        <provider android:name="TextProvider"
                android:authorities="com.testapp" />
    </application>
    <uses-sdk android:minSdkVersion="3" />
</manifest>

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.testapp2"
      android:versionCode="1"
      android:versionName="1.0" android:sharedUserId="@string/myTestSharedUser">
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:process="@string/automprocess">
        <provider android:name="TextProvider"
                android:authorities="com.testapp2" android:process="@string/automprocess" />
    </application>
    <uses-sdk android:minSdkVersion="3" />
</manifest>

the first manifest is an activity which retrieves information from the contentprovider from the second application (second Manifest). @string/automprocess and @string/myTestSharedUser is set to the same value in both applications. Both applications are developed and compiled in the same machine so should have the same signature. But even so, when I try the activity and retrieve from ContentProvider then run `ps` the PID for both applications is different. What can I do to get it to run in same PID?
 
signature = entity type
pid = instance id

Separate instances will never share a process id.

You'll need to make the two apps talk to each other -- for instance by using a content provider/resolver pair, with one app serving the provider and the other app using a resolver to consume it, based on the content URI.

Or is there some particular reason this is not good enough for your situation?
 
Upvote 0
I've done timing tests and it take three times longer to access through a ContentProvider if the ContentProvider is running in a seperate process and an IPC is required to access the data.

Separate instances will never share a process id.
I'm not sure what you mean by this, from android documentation, two applications can shared the same process id if they of the same sharedUserId, process and signature.
<application> | Android Developers
 
Upvote 0
It seems you clearly know more about this than I do. I haven't before heard of apps being able to share processes like this.

Reading the man pages, I came across this:
Note that for them to actually get the same user ID, they must also be signed with the same signature.
I wonder if this is the source of your trouble, that you haven't signed both apps with the same certificate?

Also, this thread talks about problems with using certificate signatures, but it's a year old so it may not apply anymore. Still, there is some mention on how to include signatures in the manifest that you might want to have a look at.

I'll shut up now, before I say even more that's wrong. :D

Good luck!
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones