I define a class Rect and a aidl file as below:

Rect.java:
package linda.test;
import android.os.Parcel;
import android.os.Parcelable;

public class Rect implements Parcelable {
   public int left;
   public int top;
   public int right;
   public int bottom;

   public static final Parcelable.Creator<Rect> CREATOR = new
Parcelable.Creator<Rect>() {
       public Rect createFromParcel(Parcel in) {
           return new Rect(in);
       }

       public Rect[] newArray(int size) {
           return new Rect[size];
       }
   };

   public Rect() {
   }

   private Rect(Parcel in) {
       readFromParcel(in);
   }

       public int getTop(){
               return top;
       }

   public void writeToParcel(Parcel out, int i) {
       out.writeInt(left);
       out.writeInt(top);
       out.writeInt(right);
       out.writeInt(bottom);
   }

   public void readFromParcel(Parcel in) {
       left = in.readInt();
       top = in.readInt();
       right = in.readInt();
       bottom = in.readInt();
   }

       public int  describeContents  (){
               return 0;
       }
}

Rect.aidl
package linda.test;
import android.os.Parcel;
import android.os.Parcelable;

parcelable Rect;

And then i create a service and aidl file as below:
MyService.java
package linda.test;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.IBinder;
import android.util.Log;
import android.content.ContentResolver;
import android.app.Activity;
import android.content.IntentFilter;

import java.io.*;
import java.util.*;
import android.os.Parcel;
import linda.test.Rest;

public class MyService extends Service {
       public MyService(){
               mService = this;
       }

       public static void startService(final Context context){
               if (mService != null)
                       return;
               context.startService(new Intent(context,
MyService.class));
               return;
       }

       public static void stopService(final Context context){
               if (mService == null)
                       return;
               context.stopService(new Intent(context,
MyService.class));
               return;
       }

       @Override
       public IBinder onBind(Intent intent) {
               if (IMyService.class.getName().equals(intent.getAction
())){
                       return mBinder;
               }else if (false){

               }
               return null;
       }

       /*
        * Public service interfaces
        */
       private final IMyService.Stub mBinder = new IMyService.Stub(){

               public Rect testSetRect(int a, int b, int c, int d){
                       Rect rect = new Rect();
                       rect.left = a;
                       rect.right = b;
                       rect.top = c;
                       rect.bottom = d;
                       return rect;
               }
       };

       @Override
       public void onCreate(){
               super.onCreate();
       }

       @Override
       public void onDestroy(){
               super.onDestroy();
       }
}

IMyService.aidl:
interface IMyService{
       Rect testSetRect(int a, int b, int c, int d);
}

and there is an activity "AidlTest" will call function "Rect
testSetRect(int a, int b, int c, int d); ", so i copy Rect.aidl and
IMyService.aidl file to the acitivty folder, add IMyService.aidl path
in Android.mk, then build AidlTest, the following error happens:

out/target/common/obj/APPS/AidlTest_intermediates/src/src/linda/test/
MyService.java:12: cannot find symbol
symbol  : class Rect
location: package linda.test
import linda.test.Rect;
                     ^
out/target/common/obj/APPS/AidlTest_intermediates/src/src/linda/test/
MyService.java:214: cannot find symbol
symbol  : class Rect
location: package linda.test
public linda.test.Rect testSetRect(int a, int b, int c, int d) throws
android.os.RemoteException;
                    ^
out/target/common/obj/APPS/AidlTest_intermediates/src/src/linda/test/
MyService.java:179: cannot find symbol
symbol  : class Rect
location: package linda.test
public linda.test.Rect testSetRect(int a, int b, int c, int d) throws
android.os.RemoteException
                    ^
vendor/oms/apps/aidl_test/src/bear/test/AidlTest.java:21: cannot find
symbol
symbol  : class Rect
location: package linda.test
import linda.test.Rect;
                     ^
out/target/common/obj/APPS/AidlTest_intermediates/src/src/linda/test/
MyService.java:95: cannot find symbol
symbol  : class Rect
location: package linda.test
olinda.test.Rect _result = this.testSetRect(_arg0, _arg1, _arg2,
_arg3);
             ^
out/target/common/obj/APPS/AidlTest_intermediates/src/src/linda/test/
MyService.java:183: cannot find symbol
symbol  : class Rect
location: package linda.test
linda.test.Rect _result;
             ^
out/target/common/obj/APPS/AidlTest_intermediates/src/src/linda/test/
MyService.java:193: package linda.test.Rect does not exist
_result =linda.test.Rect.CREATOR.createFromParcel(_reply);
                            ^
7 errors
make: *** [out/target/common/obj/APPS/AidlTest_intermediates/classes-
full-debug.jar] Error 41

--~--~---------~--~----~------------~-------~--~----~
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