Android Question If Java help

LuigiTasca

Member
Licensed User
Longtime User
hi everyone,
I'm integrating with a third part android service. The interaction is easy. I call the service with an intent passing a bitmap.

The problem is that in the second part of the integration I have to intercept the successful of the call.

They asked me to add this class to my source that I implemented in this way:

B4X:
#if java
    import android.os.Bundle;
    import android.os.Handler;
    import android.os.Parcel;
    import android.os.ResultReceiver;
    import android.media.session.MediaSession.*;
    import android.content.Intent;
    import anywheresoftware.b4a.objects.IntentWrapper;
    public class PrinterResultReceiver extends ResultReceiver{
        private Receiver receiver;
        public PrinterResultReceiver(Receiver r) {
            super(new Handler() );
            this.receiver = r;      
        }
        //public interface Receiver {
        public interface Receiver {
            void onReceivePrinterResult(int resultCode);          
        }
        @Override
        protected void onReceiveResult(int resultCode, Bundle resultData) {
            if(null!=this.receiver){
                this.receiver.onReceivePrinterResult(resultCode);
            }
        }
        public ResultReceiver asResultReceiver() {
            Parcel parcel = Parcel.obtain();
            this.writeToParcel(parcel,0);
            parcel.setDataPosition(0);      
            ResultReceiver = receiverForSending = ResultReceiver.CREATOR.createFromParcel(parcel);
            parcel.recycle();
            return receiverForSending;
        }
    }
#End If

But I get this error if I try to run it:

B4A line: 12
End Sub
javac 1.8.0_144
src\com\GenialFood\POS\paxprintservice.java:91: error: Illegal static declaration in inner class paxprintservice.PrinterResultReceiver
public interface Receiver {
^
modifier 'static' is only allowed in constant variable declarations


Then I have to implement this method (That I'll use to know if the service successifully printed my bitmap)

B4X:
public void onReceivePrinterResult(int result){
'my conditions
}

How can I interact with the java code? Can somebody help me, please?
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…