Hi,

As I noted on the issue, you should avoid the reverse binding for now and use 
Go interfaces instead. The following change to the gomobile bind example 
demonstrates the technique:

diff --git 
a/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
 
b/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
index 47248d9..fce9a7b 100644
--- 
a/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
+++ 
b/example/bind/android/app/src/main/java/org/golang/example/bind/MainActivity.java
@@ -11,6 +11,8 @@ import android.os.Bundle;
 import android.widget.TextView;
 
 import hello.Hello;
+import hello.ContentProvider;
+import hello.Writer;
 
 public class MainActivity extends Activity {
 
@@ -25,5 +27,16 @@ public class MainActivity extends Activity {
         // Call Go function.
         String greetings = Hello.greetings("Android and Gopher");
         mTextView.setText(greetings);
+
+               Hello.initContentProvider(new ContentProvider() {
+                       @Override public Writer open(String name) throws 
Exception {
+                               return new Writer() {
+                                       @Override public long write(byte[] 
data) throws Exception {
+                                               return 0;
+                                       }
+                               };
+                       }
+               });
+               Hello.useContentProvider();
     }
 }
diff --git a/example/bind/android/hello/build.gradle 
b/example/bind/android/hello/build.gradle
index 92fb0bd..11345e4 100644
--- a/example/bind/android/hello/build.gradle
+++ b/example/bind/android/hello/build.gradle
@@ -4,7 +4,7 @@
  */
 
 plugins {
-    id "org.golang.mobile.bind" version "0.2.9"
+    id "org.golang.mobile.bind" version "0.2.7"
 }
 
 gobind {
diff --git a/example/bind/hello/hello.go b/example/bind/hello/hello.go
index 2d98ff9..96301da 100644
--- a/example/bind/hello/hello.go
+++ b/example/bind/hello/hello.go
@@ -10,3 +10,28 @@ import "fmt"
 func Greetings(name string) string {
        return fmt.Sprintf("Hello, %s!", name)
 }
+
+var contentProvider ContentProvider
+
+type ContentProvider interface {
+       Open(name string) (Writer, error)
+}
+
+type Writer interface {
+       Write(b []byte) (int, error)
+}
+
+func InitContentProvider(cp ContentProvider) {
+       contentProvider = cp
+}
+
+func UseContentProvider() {
+       w, err := contentProvider.Open("test")
+       if err != nil {
+               // handle error
+       }
+       _, err = w.Write([]byte("data"))
+       if err != nil {
+               // handle error
+       }
+}


The gobind plugin downgrade is https://github.com/golang/go/issues/21594.

 - elias

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to