Hello,

I need to make a service usable from other applications, I'm trying
the following:

First eclipse Project:
- Service.java: The class that extend the Service.
- MainActivity.java: Activity that only launch the service.
- MyInterface.aidl: The interface to comunicate with teh service.
- Manifest.xml: I've added the following:

       <service android:name="Service" android:exported="true"
                  class="Service" android:process=":remote">
                <intent-filter>
                        <action android:name="Test.Service.MyInterface"/>
                        <action android:name="Test.Service.REMOTE_SERVICE"/>
                </intent-filter>
        </service>


Second eclipse Project:
- MyInterface.aidl: The same interface than in the first project.
- MyActivity.java: The activity which need use the service.

        private MyInterface mService = null;
        private int res = -2;

        private ServiceConnection mConnection;

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

                mConnection = new ServiceConnection() {
                        @Override
                        public void onServiceConnected(ComponentName className, 
IBinder
service) {
                                mService = 
MyInterface.Stub.asInterface(service);
                        }
                        @Override
                        public void onServiceDisconnected(ComponentName name) {
                                mService = null;
                        }
                };

                Intent i = new Intent(MyInterface.class.getName());
                Boolean b = bindService(i, mConnection, 
Context.BIND_AUTO_CREATE);

                try {
                        res = mService.requestAd();
                } catch (Exception e) {
                        Log.e("Log","RequestAd: "+e.getMessage());
                }
        }


My problem is that in the second project, when I run it, I obtain "b =
false", It's means that the bindService doesnt work properly.

Could anyone help me? I don't know what I have doing wrong.

Thank's in advance.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to