document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. public class MyReceiver extends BroadcastReceiver {
  2.    
  3.     private static MyReceiver instance;
  4.    
  5.     // text that will be read by Unity
  6.     public static String text = "";
  7.    
  8.     // Triggered when an Intent is catched
  9.     @Override
  10.     public void onReceive(Context context, Intent intent) {
  11.         // We get the data the Intent has
  12.         String sentIntent = intent.getStringExtra(Intent.EXTRA_TEXT);
  13.         if (sentIntent != null) {
  14.             // We assigned it to our static variable
  15.             text = intentText;
  16.         }
  17.     }
  18.  
  19.     // static method to create our receiver object, it\'ll be Unity that will create ou receiver object (singleton)
  20.     public static void createInstance()
  21.     {
  22.         if(instance ==  null)
  23.         {
  24.             instance = new MyReceiver();
  25.         }
  26.        
  27.     }
  28. }
');