1. Download our Official Android App: Forums for Android!

Apps Sharing two apps to share process id

Discussion in 'Android Development' started by emnaki, Jul 21, 2009.

  1. emnaki

    emnaki Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 13, 2009

    Jul 13, 2009
    4
    0
    5
    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 (Text):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    4.       package="com.testapp"
    5.       android:versionCode="1"
    6.       android:versionName="1.0" android:sharedUserId="@string/myTestSharedUser">
    7.     <application android:icon="@drawable/icon" android:label="@string/app_name" android:process="@string/automprocess">
    8.         <activity android:name=".testapp"
    9.                   android:label="@string/app_name">
    10.             <intent-filter>
    11.                 <action android:name="android.intent.action.MAIN" />
    12.                 <category android:name="android.intent.category.LAUNCHER" />
    13.             </intent-filter>            
    14.         </activity>
    15.         <provider android:name="TextProvider"
    16.                 android:authorities="com.testapp" />
    17.     </application>
    18.     <uses-sdk android:minSdkVersion="3" />
    19. </manifest>
    20.  
    Code (Text):
    1.  
    2. <?xml version="1.0" encoding="utf-8"?>
    3. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    4.       package="com.testapp2"
    5.       android:versionCode="1"
    6.       android:versionName="1.0" android:sharedUserId="@string/myTestSharedUser">
    7.     <application android:icon="@drawable/icon" android:label="@string/app_name" android:process="@string/automprocess">
    8.         <provider android:name="TextProvider"
    9.                 android:authorities="com.testapp2" android:process="@string/automprocess" />
    10.     </application>
    11.     <uses-sdk android:minSdkVersion="3" />
    12. </manifest>
    13.  
    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?
     

    Advertisement

  2. KlaymenDK

    KlaymenDK Android Expert
    Rank:
    None
    Points:
    143
    Posts:
    1,217
    Joined:
    May 29, 2009

    May 29, 2009
    1,217
    130
    143
    Denmark
    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?
     
  3. emnaki

    emnaki Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 13, 2009

    Jul 13, 2009
    4
    0
    5
    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.

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

    KlaymenDK Android Expert
    Rank:
    None
    Points:
    143
    Posts:
    1,217
    Joined:
    May 29, 2009

    May 29, 2009
    1,217
    130
    143
    Denmark
    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:
    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!
     

Share This Page

Loading...