views:

45

answers:

0

Hi,

I know there are many posts around the issue I am facing but I havent been able to see any yet which addresses my issue.

This is what I am doing:

  1. Create 2 apks. (1 with an activity - lets call it F1App and 2nd with a service - F1Service)
  2. Both APKs have same sharedUserId and same android.process and are signed with the same key - I have been able to confirm that the 2 are now running in the same process.
  3. From App 1 I bind to F1Service
  4. Bind returns successfully but I am unable to access the classes using the binder. The same code works fine in the sample code but the 2 there are in the same apk.

Here is the F1App code.

package f1.f1;

import com.fusionone.F1Service;


public class F1App extends Activity {
   private boolean mIsBound;
   public F1Service mBoundService;

   @Override
       protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

       setContentView(R.layout.layout);

       // Watch for button clicks.
       Button button = (Button)findViewById(R.id.bind);
       button.setOnClickListener(mBindListener);
       button = (Button)findViewById(R.id.unbind);
       button.setOnClickListener(mUnbindListener);
   }

   private ServiceConnection mConnection = new ServiceConnection() {
       public void onServiceConnected(ComponentName className,
IBinder service) {
               Log.d("Got Binder", "Got Binder" + service);
               mBoundService =
((F1Service.LocalBinder)service).getService();
       }

       public void onServiceDisconnected(ComponentName className) {
           mBoundService = null;
           Toast.makeText(F1App.this,
R.string.local_service_disconnected,Toast.LENGTH_SHORT).show();
       }
   };

   private OnClickListener mBindListener = new OnClickListener() {
       public void onClick(View v) {
               Intent toSend = new Intent("com.fusionone.F1Service");
               bindService(toSend, mConnection, Context.BIND_AUTO_CREATE);
               mIsBound = true;
       }
   };

   private OnClickListener mUnbindListener = new OnClickListener() {
       public void onClick(View v) {
           if (mIsBound) {
               // Detach our existing connection.
               unbindService(mConnection);
               mIsBound = false;
           }
       }
   };
}




Now the F1Service looks like this:

public class F1Service extends Service {
   private NotificationManager mNM;

   public static class LocalBinder extends Binder {
       public static F1Service myServiceObj;
       LocalBinder(F1Service x){
               myServiceObj = x;
       }
       public F1Service getService() {
           return myServiceObj;
       }
   }

   @Override
   public void onCreate() {
       mNM =
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);

       showNotification();
   }

   @Override
   public void onDestroy() {

       //Toast.makeText(this, R.string.local_service_stopped,
Toast.LENGTH_SHORT).show();
   }

   @Override
   public IBinder onBind(Intent intent) {
       return mBinder;
   }

   private final IBinder mBinder = new LocalBinder(this);

   private void showNotification() {
   }
}

The error I get is during install time:

I/ActivityManager(  563): Start proc f1process.myprocess for activity
f1.f1/.F1A
pp: pid=1556 uid=10024 gids={}
D/dalvikvm( 1548): LinearAlloc 0x0 used 676436 of 4194304 (16%)
I/jdwp    ( 1556): received file descriptor 10 from ADB
D/ddm-heap( 1556): Got feature list request
W/ActivityThread( 1556): Application f1.f1 is waiting for the debugger
on port 8
100...
I/System.out( 1556): Sending WAIT chunk
I/dalvikvm( 1556): Debugger is active
I/System.out( 1556): Debugger has connected
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): waiting for debugger to settle...
I/System.out( 1556): debugger has settled (1433)
E/dalvikvm( 1556): Could not find class 'com.fusionone.F1Service
$LocalBinder', r
eferenced from method f1.f1.F1App$1.onServiceConnected
W/dalvikvm( 1556): VFY: unable to resolve check-cast 13 (Lcom/
fusionone/F1Servic
e$LocalBinder;) in Lf1/f1/F1App$1;
W/dalvikvm( 1556): VFY:  rejecting opcode 0x1f at 0x0018
W/dalvikvm( 1556): VFY:  rejected Lf1/f1/F1App$1;.onServiceConnected
(Landroid/c
ontent/ComponentName;Landroid/os/IBinder;)V
W/dalvikvm( 1556): Verifier rejected class Lf1/f1/F1App$1;

I would really appreciate all help on this!

Thanks!