I’m trying to create a module to share simple data such as this link. I don’t get any errors when I compile with the following code:
using Fuse;
using Fuse.Scripting;
using Fuse.Reactive;
using Uno.UX;
using Uno.Compiler.ExportTargetInterop;
[ForeignInclude(Language.Java, "android.content.Intent")]
[ForeignInclude(Language.Java, "com.fuse.Activity")]
[UXGlobalModule]
public class Share : NativeModule
{
static readonly Share _instance;
public Share()
{
// Make sure we're only initializing the module once
if(_instance != null) return;
_instance = this;
Resource.SetGlobalKey(_instance, "Share");
AddMember(new NativeFunction("SendIntent", (NativeCallback)SendIntent));
}
static object SendIntent(Context c, object[] args)
{
SendIntent();
return null;
}
[Foreign(Language.Java)]
static extern(Android) void SendIntent()
@{
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
Activity.getRootActivity().startActivity(Intent.createChooser(sendIntent, "Share via..."));
@}
}
<App>
<ClientPanel>
<JavaScript>
var Share = require("Share");
function share() { Share.sendIntent(); }
module.exports = {
share: share
};
</JavaScript>
<Button Clicked="{share}" Text="SHARE" />
</ClientPanel>
</App>
But when I click the button the application stops unexpectedly and I get this error:
D/AndroidRuntime( 3014): Shutting down VM
W/dalvikvm( 3014): threadid=1: thread exiting with uncaught exception (group=0x41a22c98)
W/dalvikvm( 3014): threadid=1: uncaught exception occurred
W/System.err( 3014): java.lang.RuntimeException: Uno.Exception: Unhandled exception ---> Uno.Exception: Unexpected exception ---> Uno.Exception: Unexpected exception ---> Fuse.Scripting.ScriptException:
W/System.err( 3014): --- End of inner exception stack trace ---
W/System.err( 3014): --- End of inner exception stack trace ---
W/System.err( 3014): --- End of inner exception stack trace ---
W/System.err( 3014): at com.Bindings.ExternedBlockHost.callUno_Fuse_App_OnFrameCallback245(Native Method)
W/System.err( 3014): at com.foreign.Fuse.App$1.doFrame(App.java:39)
W/System.err( 3014): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:786)
W/System.err( 3014): at android.view.Choreographer.doCallbacks(Choreographer.java:591)
W/System.err( 3014): at android.view.Choreographer.doFrame(Choreographer.java:559)
W/System.err( 3014): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
W/System.err( 3014): at android.os.Handler.handleCallback(Handler.java:808)
W/System.err( 3014): at android.os.Handler.dispatchMessage(Handler.java:103)
W/System.err( 3014): at android.os.Looper.loop(Looper.java:193)
W/System.err( 3014): at android.app.ActivityThread.main(ActivityThread.java:5292)
W/System.err( 3014): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err( 3014): at java.lang.reflect.Method.invoke(Method.java:515)
W/System.err( 3014): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:824)
W/System.err( 3014): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:640)
W/System.err( 3014): at dalvik.system.NativeStart.main(Native Method)
Can anyone tell me what is the problem?