前提
「Android用にビルドしたUnity」 - 「AndroidNative」 - 「RaspberryPi(Node.js)」 3点間のデータ送受信についての質問です。
前提ですが、
Androidがスリープ状態であっても、AndroidNative - RaspberryPi間の通信が出来るように、
メインのActivity上でServiceクラスをstartServiceし、
そのServiceクラス上に、RaspberryPiとの通信を行うMessageListenerクラスを実装しています。
また、Unity - AndroidNative間の通信には、
AndroidNative上の「UnityPlayer.UnitySendMessage」関数と、Unity上の「Androidのネイティブプラグイン」を用いる予定です。
質問
Android用にビルドしたUnityからAndroidのネイティブプラグインを実行し、
メインのActivityにIntentしたService上のMessageListenerインスタンスに文字列を送りたいのですが、
ネイティブプラグインからService上のインスタンスへアクセスする方法が分からず困っています。ご教授いただけると幸いです。
追記
Androidプラグイン上のクラスをインスタンス化して、現在のActivityのFragmentManagerに追加しているコードを見つけたのですが、この繋がりを経由してプラグイン→Activityへの文字列の送信は可能でしょうか。
Java
1package com.eppz.plugins; 2public class EPPZ_Alert extends Fragment 3{ 4 public static EPPZ_Alert instance; // Singleton instance 5 public static void start() 6 { 7 // Instantiate Fragment. 8 instance = new EPPZ_Alert_Fragment(); 9 // Add to the current 'Activity' (a static reference is stored in 'UnityPlayer'). 10 UnityPlayer.currentActivity.getFragmentManager().beginTransaction().add(instance, "EPPZ_Alert").commit(); 11 } 12 ... 13}
あなたの回答
tips
プレビュー