3

I am new to Android and was working on iOS for the longest time imaginable. Just have a basic question regarding the protocol class. Here is my protocol class in iOS:

#import "ServiceBaseProtocol.h"
#import "ServiceTasksProtocol.h"

@protocol AnswersServiceProtocol <ServiceBaseProtocol>
- (NSUInteger)answersQueryIntentForTarget:(id<ServiceTaskCallbackProtocol>)target requestInput:(NSString*)requestInput;
@end

Is it possible to convert this into equivalent android code. How do I go about the same?

3
  • 1
    You might consider explaining what this is, since not every Android developer is an iOS developer. Commented Aug 13, 2013 at 18:38
  • en.wikipedia.org/wiki/Interface_(Java) Commented Aug 13, 2013 at 18:41
  • Protocol is not a class, by the way. Protocol defines an interface. And how do you define an interface in java? Using an abstract class or using interface keyword. Note the two languages are pretty different, you can't directly translate everything from one language to another. Commented Aug 13, 2013 at 18:57

1 Answer 1

3

Protocols are called interfaces in Java. So your piece of code might look like:

 public interface AnswersServiceProtocol extends ServiceBaseProtocol
 {
    public int answersQueryIntentForTargetAndRequestInput(ServiceTaskCallbackProtocol target, String requestInput);
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.