Hi All,

When my client code calls bindService it was fine and it calls
onServiceConnected, there i am calling the interface method using the
XXXX.Stub.asInterface(service) object and there only it gives me bunch
of error as:

02-13 17:14:52.239: WARN/Parcel(1035): **** enforceInterface()
expected 'oem.android.proj1.IRemoteService' but read
'oem.android.proj2.IRemoteService'
02-13 17:14:52.249: DEBUG/AndroidRuntime(1071): Shutting down VM
02-13 17:14:52.249: WARN/dalvikvm(1071): threadid=3: thread exiting
with uncaught exception (group=0x40010e28)
02-13 17:14:52.249: ERROR/AndroidRuntime(1071): Uncaught handler:
thread main exiting due to uncaught exception
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):
java.lang.SecurityException: Binder invocation to an incorrect
interface
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.os.Parcel.readException(Parcel.java:1234)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.os.Parcel.readException(Parcel.java:1222)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
oem.android.proj2.IRemoteService$Stub$Proxy.display
(IRemoteService.java:108)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
oem.android.proj2.RemoteServiceBinding.onListItemClick
(RemoteServiceBinding.java:147)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.app.ListActivity$2.onItemClick(ListActivity.java:312)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.widget.AdapterView.performItemClick(AdapterView.java:283)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.widget.ListView.performItemClick(ListView.java:3049)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.widget.AbsListView$PerformClick.run(AbsListView.java:1415)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.os.Handler.handleCallback(Handler.java:542)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.os.Handler.dispatchMessage(Handler.java:86)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.os.Looper.loop(Looper.java:123)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
android.app.ActivityThread.main(ActivityThread.java:3742)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
java.lang.reflect.Method.invokeNative(Native Method)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
java.lang.reflect.Method.invoke(Method.java:515)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:739)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
02-13 17:14:52.259: ERROR/AndroidRuntime(1071):     at
dalvik.system.NativeStart.main(Native Method)

My Server and Client code both are in different package i mean in
different .APK.

I have ran the Service code first and these are the below files i am
using:
IRemoteService.aidl -> have the interfaces
DisplayPage.java --> Activity that starts the RemoteService.java
RemoteService.java  --> Service and impliments the interface methods

AndroidManifest.xml code:
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".DisplayPage" android:label="@string/
app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
            </intent-filter>      </activity>
        <service android:name="RemoteService" android:exported="true"
                 class="RemoteService" android:process=":remote">
        <intent-filter>
        <action android:name="oem.android.proj2.IRemoteService"/>
        <action android:name="oem.android.proj2.REMOTE_SERVICE"/>
        </intent-filter> </service>
    </application>

IRemoteService.aidl  code:
package oem.android.proj1;

interface IRemoteService{
    void display();

RemoteService.java  code:
package oem.android.proj1;
public class RemoteService extends Service {
        public void onCreate() {
        super.onCreate(); }
        public IBinder onBind(Intent intent) {
                If (IRemoteService.class.getName().equals(intent.getAction())){
                return mBinder;         }
                return mBinder;}}

private final IRemoteService.Stub mBinder = new IRemoteService.Stub(){
                public void display(){
                Toast.makeText(RemoteService.this, "RemoteService -- display
function",
                        Toast.LENGTH_SHORT).show();    }
            };}


Then i ran the Client code and these are the below files i am using:
IRemoteService.aidl -> have the interfaces
RemoteServiceBinding.java --> Activity that that calls the bindService
and calls the Service's methods.
AndroidManifest.xml code:
    <application android:icon="@drawable/icon" android:label="@string/
app_name">
        <activity android:name=".RemoteServiceBinding"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.LAUNCHER" />
                <action
android:name="oem.android.proj1.IRemoteService"/>
                <action
android:name="oem.android.proj1.IRemoteService.display"/
>
            </intent-filter>
        </activity>

IRemoteService.aidl  code:
package oem.android.proj1;

interface IRemoteService{
    void display();

RemoteServiceBinding.java code:
package oem.android.proj2;

public class RemoteServiceBinding extends ListActivity {
        private Context ctx;
        IRemoteService mService = null;
        private String[] mStrings = {"Bind", "Conn"};
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                XXXXXXXXX}

private ServiceConnection mConnection = new ServiceConnection() {
            public void onServiceConnected(ComponentName
className,IBinder service) {
                mService = IRemoteService.Stub.asInterface(service);

            }
                public void onServiceDisconnected(ComponentName name) {
                    mService = null;}
            };
protected void onListItemClick(ListView l, View v, int position, long
id)
            {
                if(position ==0)
                {
                        bindService(new Intent(IRemoteService.class.getName
()),
                            mConnection, Context.BIND_AUTO_CREATE);

                }
                if(position ==1)
                {
                         try {
                                                mService.display();
                                        } catch (RemoteException e) {
                                                // TODO Auto-generated catch 
block
                                                e.printStackTrace();
                                        }               }
            }


i have set the ListItem listener when i press my bind one it should
call the bindService and it is doing correctly, but when i click the
Conn it should call my   display() method but is giving me errors that
i have mentioned on the top.

Can someone plz help me what went wrong on my code, i am assuming that
some thing broken in my AndroidManifest.xml code only.

Actually i am still in dilema what all thing to set in
AndroidManifest.xml file in both Client and Server site, like
permisson or any other things.

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

Reply via email to