We can use Native plugin to send content to other apps in Android:
First, install bridge or native plugin.
Lua code within ui-android.lua:
--[[
SHARE INTENT
]]--
Share = Core.class()
function Share:init()
local share = native.getClass("com.giderosmobile.android.Share")
share.sendText(activity)
end |
and create the following Share class in java:
package com.giderosmobile.android;
import android.app.Activity;
import android.content.Intent;
import android.util.Log;
/**
* Send content to other apps
*
*/
public class Share {
public static void sendText(Activity activity)
{
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.startActivity(sendIntent);
}
} |
Just use the following lua code to send text content
local share = ui.Share.new() |
Comments
Likes: keszegh, pie
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: totebo
Fragmenter - animated loop machine and IKONOMIKON - the memory game
native plugin is working great, I need to play with this
see the sample in gideros all plugins folder.
Likes: vitalitymobile
Fragmenter - animated loop machine and IKONOMIKON - the memory game
That way we can call almost native Android/iOS libraries like data analytics, ads network, utility ...
And there was a jvbridge for Android by @Javi
Then @ar2rsawseen make a native plugin for android
We can use "BHwax" and "jvbridge" as the keyword to search the forum for more information.
in: C:\Program Files (x86)\Gideros\All Plugins\native\bin\Android\src\com\giderosmobile\android\plugins\bridge
or: C:\Program Files (x86)\Gideros\All Plugins\native\source\Android\src\com\giderosmobile\android\plugins\bridge
- from inside gideros
- from android studio
I exported the native project from gideros to android studio but it is not nice to see Android studio just won't compile the project because of class name conflicts, ...
So second solution would be to try from inside gideros, but where do we put the share java class?
P.S. I also tried to call only native.getClass("com.giderosmobile.android.plugins.bridge.GBridge"), but result is the same.
Likes: MoKaLux
JNI DETECTED ERROR IN APPLICATION: illegal class name 'com.giderosmobile.android.plugins.bridge.GBridge'
java_vm_ext.cc:577] (should be of the form 'package/Class', [Lpackage/Class;' or '[[B')
java_vm_ext.cc:577] in call to FindClass
Last time when I test, I can resolve it by signing it with a keystone (not debug key)
http://forum.giderosmobile.com/discussion/comment/57466/#Comment_57466
http://forum.giderosmobile.com/discussion/5392/android-l-lollipop-doesnt-like-gideros
But today when trying to build a test with a real Keystore on android 11, I still have the above error.
We must try to fix it now...
I will give it another try in the future when need arises.
PEACE.
What kind of plugin do you think can be done with the native plugin?
Now this code works:
The error is now:
Likes: MoKaLux
Likes: vitalitymobile
Signed release APK (android 8.0+):
https://drive.google.com/file/d/11O3P_4AOa-A0wqlZGQAA78oTG5UvITqT/view?usp=sharing
So at least, with android 10, we can use and test the native plugin.
Android 11 will be coming soon in this July and I think we should fix this problem
(I install your app, it open well, when press Share button, it errrors)
2020-07-02 11:13:59.652 11459-11483/? A/rdomain.yourap: runtime.cc:662] JNI DETECTED ERROR IN APPLICATION: illegal class name 'com.giderosmobile.android.plugins.bridge.GBridge'
runtime.cc:662] (should be of the form 'package/Class', [Lpackage/Class;' or '[[B')
runtime.cc:662] in call to FindClass
runtime.cc:662] from void com.giderosmobile.android.player.GiderosApplication.nativeDrawFrame()
--------- beginning of crash
2020-07-02 11:13:59.652 11459-11483/? A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 11483 (GLThread 6746), pid 11459 (rdomain.yourapp)
2020-07-02 11:13:59.683 11508-11508/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: Build fingerprint: 'google/flame/flame:11/RPB1.200504.020/6557529:user/release-keys'
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: Revision: 'MP1.0'
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: ABI: 'arm64'
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: Timestamp: 2020-07-02 11:13:59+0700
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: pid: 11459, tid: 11483, name: GLThread 6746 >>> com.yourdomain.yourapp <<<
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: uid: 10277
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
2020-07-02 11:13:59.684 11508-11508/? A/DEBUG: Abort message: 'JNI DETECTED ERROR IN APPLICATION: illegal class name 'com.giderosmobile.android.plugins.bridge.GBridge'
(should be of the form 'package/Class', [Lpackage/Class;' or '[[B')
in call to FindClass
from void com.giderosmobile.android.player.GiderosApplication.nativeDrawFrame()'
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Likes: vitalitymobile, MoKaLux, rrraptor
Using your patch, we can still use dot symbol (.), not the slash (/)
if not native then
require "native"
end
local bridge = native.getClass("com.giderosmobile.android.plugins.bridge.GBridge")
local activity = bridge.getActivity()
local toast = native.getClass("android.widget.Toast")
local t = toast.makeText(activity, "Hello Gideros", 2)
t:show()
Likes: MoKaLux
Likes: MoKaLux, vitalitymobile
Usage:
https://deluxepixel.com
First,
import android.content.Intent;
And finally: