Using custom classes in AIDL interface

Put your problem here if it does not fit any of the other categories.

Using custom classes in AIDL interface

Postby Tuba » Wed Jun 23, 2010 9:31 pm

As described in manual, to use custom class in .aidl files, it must to implement Parcelable interface :

Code: Select all
package com.shadower;

import android.os.Parcel;
import android.os.Parcelable;

public class Params implements Parcelable{
   private long timeout;

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

      @Override
      public Params[] newArray(int size) {
         return new Params[size];
      }
   };

   public Params(Parcel in) {
      timeout = in.readLong();
   }

   public void writeToParcel(Parcel out) {
      out.writeLong(timeout);
   }

   public void setTimeOut(long timeout) {
      this.timeout = timeout;
   }
   
   public long getTimeout() {
      return timeout;
   }

   @Override
   public int describeContents() {
      return 0;
   }

   @Override
   public void writeToParcel(Parcel out, int flags) {
      out.writeLong(timeout);
   }
}


then must be imported into .aidl:
Code: Select all
package com.shadower;

import com.shadower.IShadowerServiceCallback;
import com.shadower.Params;
....


but shit happens :

Code: Select all
couldn't find import for class com.shadower.Params   IShadowerService.aidl   /shadower/src/com/shadower   line 5   Android AIDL Problem


wtf is going on?
[url="http://www.goandroid.net"]GoAndroid - Google Android[/url]
Tuba
Freshman
Freshman
 
Posts: 7
Joined: Sun Jul 20, 2008 5:43 pm

Top

Re: Using custom classes in AIDL interface

Postby Tuba » Thu Jun 24, 2010 8:22 am

hello?
[url="http://www.goandroid.net"]GoAndroid - Google Android[/url]
Tuba
Freshman
Freshman
 
Posts: 7
Joined: Sun Jul 20, 2008 5:43 pm

Re: Using custom classes in AIDL interface

Postby padde » Thu Jun 24, 2010 4:26 pm

Hi !
padde
Master Developer
Master Developer
 
Posts: 443
Joined: Wed Apr 08, 2009 4:52 pm

Re: Using custom classes in AIDL interface

Postby Tuba » Thu Jun 24, 2010 8:33 pm

Hey, man?! Can't you help me with my troube?
[url="http://www.goandroid.net"]GoAndroid - Google Android[/url]
Tuba
Freshman
Freshman
 
Posts: 7
Joined: Sun Jul 20, 2008 5:43 pm

Re: Using custom classes in AIDL interface

Postby steven_andriod » Thu Nov 11, 2010 6:28 am

this is so easy!
you must create a .aidl file like this:

package com....;
parcelable Params;
steven_andriod
Freshman
Freshman
 
Posts: 3
Joined: Sat Oct 30, 2010 9:00 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 26 guests