Android share photo, Cerberus Xtension

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
715
This Cerberus Xtension is an Android example

This example shows how you could add functionality to share photos from Cerberus on your Android device.

example.cxs
Code:
Strict
Import mojo2
Import "commands.java"

Extern
Function SharePhoto:Void(address:String) = "commands.SharePhoto"
Public

Function Main:Int()
    New Application()
    Return 0
End

Class Application Extends App Final
   
    Field canvas:Canvas
    Field image:Image
   
    Method OnCreate:Int()
        canvas = New Canvas()
        SetUpdateRate 0
        image = Image.Load("photo.jpg",0,0,0)
        Return 0
    End
   
    Method OnUpdate:Int()
        If TouchHit(0) Then SharePhoto("photo.jpg")
        If KeyHit(KEY_ESCAPE) Then OnClose() ; Return 0
        Return 0
    End
   
    Method OnRender:Int()
        canvas.Clear
        canvas.DrawImage image,0,0
        canvas.Flush
        Return 0
    End
End

commands.java
Code:
class commands
{
    static void SharePhoto(String address) {
        android.content.Intent shareIntent = new android.content.Intent(Intent.ACTION_SEND,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        shareIntent.putExtra(Intent.EXTRA_STREAM, android.net.Uri.fromFile(new File(address)));
        shareIntent.setType("image/jpeg");
        android.content.Intent send = Intent.createChooser(shareIntent,null);
        BBAndroidGame._androidGame._activity.startActivity(send);
    }
}
 

Attachments

  • Share.zip
    7.3 KB · Views: 4
Top Bottom