Last active
February 27, 2017 13:56
Star
You must be signed in to star a gist
Activity Callbacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"RootNamespace":"", | |
"Packages": [ | |
"Fuse", | |
"FuseJS", | |
"Android.ActivityUtils", | |
], | |
"Includes": [ | |
"*" | |
], | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<App> | |
<Button Text="Play" Clicked="ClickPlay" /> | |
</App> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Uno; | |
using Uno.Graphics; | |
using Uno.Platform; | |
using Uno.Collections; | |
using Fuse; | |
using Fuse.Controls; | |
using Fuse.Triggers; | |
using Fuse.Resources; | |
using Android; | |
using Uno.Compiler.ExportTargetInterop; | |
[ForeignInclude(Language.Java, | |
"android.app.Activity", | |
"android.content.Intent", | |
"android.net.Uri", | |
"android.os.Bundle", | |
"android.provider.MediaStore", | |
"java.io.File")] | |
public partial class MainView | |
{ | |
void ClickPlay(object a1, EventArgs a2) | |
{ | |
var intent = makeMyIntent(); | |
if (intent!=null) | |
{ | |
ActivityUtils.StartActivity(intent, OnResult); | |
} else { | |
debug_log "Didnt make intent. boooo"; | |
} | |
} | |
//-------------------------------------------------- | |
extern(android) void OnResult(int resultCode, Java.Object intent, object info) | |
{ | |
debug_log "\nblam!: "+resultCode+" - "+intent + "\n"; | |
} | |
[Foreign(Language.Java)] | |
static extern(android) Java.Object makeMyIntent() | |
@{ | |
try { | |
String fileName = "JPEG_TEST"; | |
String ext = ".jpg"; | |
File storageDir = com.fuse.Activity.getRootActivity().getExternalFilesDir(null); | |
File photoFile = File.createTempFile(fileName, ext, storageDir); | |
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); | |
Bundle bdl = new Bundle(); | |
bdl.putParcelable(MediaStore.EXTRA_OUTPUT, Uri.fromFile((File)photoFile)); | |
takePictureIntent.putExtras(bdl); | |
return takePictureIntent; | |
} catch (Exception ex) { | |
return null; | |
} | |
@} | |
//-------------------------------------------------- | |
extern(!android) void OnResult(int resultCode, object intent) | |
{ | |
} | |
static extern(!android) object makeMyIntent() | |
{ | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The important methods in the
ActivityUtils
class arepublic static Java.Object GetRootActivity() {..}
public static void StartActivity(Java.Object _intent)
public static void StartActivity(Java.Object intent, ActivityResultCallback callback)
where
ActivityResultCallback
is defined as