Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyReceiver extends BroadcastReceiver {
- private static MyReceiver instance;
- // text that will be read by Unity
- public static String text = "";
- // Triggered when an Intent is catched
- @Override
- public void onReceive(Context context, Intent intent) {
- // We get the data the Intent has
- String sentIntent = intent.getStringExtra(Intent.EXTRA_TEXT);
- if (sentIntent != null) {
- // We assigned it to our static variable
- text = intentText;
- }
- }
- // static method to create our receiver object, it'll be Unity that will create ou receiver object (singleton)
- public static void createInstance()
- {
- if(instance == null)
- {
- instance = new MyReceiver();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement