protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new Button(this);
            b.setText("I don't do anything, but I was added dynamically. :)");
            ll.addView(b);


            Action onclick = delegate
            {
                b.setText("onclick");
            };

            b.setText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
Exemplo n.º 2
0
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // why isnt jsc doing automatic ref?
            var r = default(global::ScriptCoreLib.Android.Windows.Forms.IAssemblyReferenceToken_Forms);

            ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext = this;

            // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\Library\ApplicationControl.cs

            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new android.widget.Button(this);

            // jsc is doing the wrong thing here
            //var SDK_INT = android.os.Build.VERSION.SDK_INT;

            //b.setText("Notify! " + new { SDK_INT, android.os.Build.VERSION.SDK });
            b.setText("Notify! ");
            int counter = 0;

            b.AtClick(
                delegate
            {
                counter++;



                var f = new Form1();

                var value = f.ShowDialog();

                b.setText("ShowDialog! " + new { value, f.textBox1.Text });
            }
                );

            ll.addView(b);

            this.setContentView(sv);
        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // why isnt jsc doing automatic ref?
            var r = default(global::ScriptCoreLib.Android.Windows.Forms.IAssemblyReferenceToken_Forms);
            ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext = this;

            // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\Library\ApplicationControl.cs

            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new android.widget.Button(this);

            // jsc is doing the wrong thing here
            //var SDK_INT = android.os.Build.VERSION.SDK_INT;

            //b.setText("Notify! " + new { SDK_INT, android.os.Build.VERSION.SDK });
            b.setText("Notify! " );
            int counter = 0;

            b.AtClick(
                delegate
            {
                counter++;



                var f = new Form1();

                var value = f.ShowDialog();

                b.setText("ShowDialog! " + new { value, f.textBox1.Text });
            }
            );

            ll.addView(b);

            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);


            
            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var activity = this;

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );


        }
        //        connect s6 via usb .
        // turn on wifi!
        // kill adb

        //"x:\util\android-sdk-windows\platform-tools\adb.exe"  tcpip 5555
        // restarting in TCP mode port: 5555

        //13: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        //    inet 192.168.1.126/24 brd 192.168.1.255 scope global wlan0
        //       valid_lft forever preferred_lft forever

        // on red
        // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect  192.168.1.126:5555
        // connected to 192.168.1.126:5555



        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151121
        // http://stackoverflow.com/questions/17513502/support-for-multi-window-app-development

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this);

            b.setText("Vibrate!");

            b.AtClick(
                delegate
                {
                    var vibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);

                    vibrator.vibrate(600);
                }
            );

            ll.addView(b);



            this.setContentView(sv);


            //this.ShowLongToast("http://my.jsc-solutions.net x");
        }
        // X:\opensource\ovr_mobile_sdk_0.5.0
        // https://developer.oculus.com/downloads/#version=mobile-0.5.0

        //<ItemGroup>
        //  <Content Include="X:\opensource\ovr_mobile_sdk_20141111\VRLib\src\**\*.*">
        //    <Link>opensource\ovr_mobile_sdk_20141111\VRLib\src\%(RecursiveDir)%(FileName)%(Extension)</Link>
        //  </Content>
        //</ItemGroup>

        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150402
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20141127
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150504/dae

        // http://stackoverflow.com/questions/9821875/where-is-buildconfig-debug
        // tested by?

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
		{
			// cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
			// Camera PTP

			// http://developer.android.com/guide/topics/ui/notifiers/notifications.html

			base.onCreate(savedInstanceState);

			ScrollView sv = new ScrollView(this);

			LinearLayout ll = new LinearLayout(this);

			ll.setOrientation(LinearLayout.VERTICAL);

			sv.addView(ll);


			Button b = new Button(this);

			b.setText("Notify!");
			int counter = 0;




			ll.addView(b);

			this.setContentView(sv);

			this.ShowToast("http://jsc-solutions.net");


		}
        // http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android
        // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest
        // http://developer.android.com/guide/topics/manifest/service-element.html

        //AtBootCompleted hack1;

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);

            var btn = new Button(this);
            btn.setText("wifi");

            ll.addView(btn);

            {
                ConnectivityManager connManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
                NetworkInfo wifiNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
                NetworkInfo mobileNetInfo = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);


                if (wifiNetInfo != null)
                    if (wifiNetInfo.isConnectedOrConnecting())
                    {
                        btn.setText("we are connected via WiFi");
                    }

                if (mobileNetInfo != null)
                    if (mobileNetInfo.isAvailable())
                        if (mobileNetInfo.isConnected())
                        {
                            btn.setText(" we are connected via mobile data (GPRS, 3G, etc.)");
                        }
            }


            this.setContentView(sv);

            this.StartPendingAlarm(typeof(NotifyService), 1000 * 1, 0);


        }
        // http://stackoverflow.com/questions/6274141/trigger-background-service-at-a-specific-time-in-android
        // http://stackoverflow.com/questions/7144908/how-is-an-intent-service-declared-in-the-android-manifest
        // http://developer.android.com/guide/topics/manifest/service-element.html


        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);

            #region startservice
            var startservice = new Button(this);
            startservice.setText("Start Service to send Notification");
            startservice.AtClick(
               delegate
               {
                   this.ShowToast("startservice_onclick");

                   var intent = new Intent(this, typeof(NotifyService).ToClass());

                   this.startService(intent);
               }
            );
            ll.addView(startservice);
            #endregion

            #region stopservice
            var stopservice = new Button(this);
            stopservice.setText("Stop Service");
            stopservice.AtClick(
                delegate
                {
                    this.ShowToast("stopservice_onclick");

                    Intent intent = new Intent();
                    intent.setAction(NotifyService.ACTION);
                    intent.putExtra("RQS", NotifyService.RQS_STOP_SERVICE);
                    this.sendBroadcast(intent);

                }
            );
            ll.addView(stopservice);
            #endregion

            this.setContentView(sv);

            this.ShowToast("http://jsc-solutions.net");


        }
        static __InitializeAndroidActivity()
        {
            Console.WriteLine("StaticInvoke");

            //  Exception Ljava/lang/RuntimeException; thrown while initializing LTryHideActionbarExperiment/StaticInvoke;
            try
            {


                // https://groups.google.com/forum/?fromgroups=#!topic/android-developers/suLMCWiG0D8
                var c = ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext;


                (ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext as Activity).runOnUiThread(
                    a =>
                    {
                        // http://stackoverflow.com/questions/4451641/change-android-layout-programatically

                        var sv = new ScrollView(a);
                        var ll = new LinearLayout(a);
                        //ll.setOrientation(LinearLayout.VERTICAL);
                        sv.addView(ll);

                        var b = new Button(a).AttachTo(ll);



                        b.WithText("before AtClick");
                        b.AtClick(
                            v =>
                            {
                                b.setText("AtClick");
                            }
                        );

                        var b2 = new Button(a);
                        b2.setText("The other button!");
                        ll.addView(b2);

                        a.setContentView(sv);
                    }
                );
            }
            catch (Exception ex)
            {
                Console.WriteLine("error: " + new { ex.Message, ex.StackTrace });
            }
        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            //// http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);


            var b = new Button(this);

            b.setText("Vibrate!");

            b.AtClick(
                delegate
                {
                    var vibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);

                    vibrator.vibrate(600);
                }
            );

            ll.addView(b);





            this.setContentView(sv);


            //this.ShowLongToast("Monese circle progressbar");

            //circularSeekbar = new CircularSeekBar(this);
            //circularSeekbar.setMaxProgress(100);
            //circularSeekbar.setProgress(100);
            //setContentView(circularSeekbar);
            //circularSeekbar.invalidate();

            //circularSeekbar.setSeekBarChangeListener(new TestAndroidCircleProgressbar.Activities.CircularSeekBar.MyOnSeekChangeListener());

        }
        // http://stackoverflow.com/questions/19954156/android-build-separate-apks-for-different-processor-architectures
        // "X:\jsc.svn\examples\java\android\Test\TestChromeAsAsset\TestChromeAsAsset.sln"

        //  [aapt] W:\bin\AndroidManifest.xml:14: error: Error: No resource found that matches the given name (at 'label' with value '@string/app_name').



        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this);

            b.setText(
                // X:\jsc.svn\examples\c\android\Test\TestNDKAsAsset\TestNDKAsAsset\Program.cs
                // http://stackoverflow.com/questions/19954156/android-build-separate-apks-for-different-processor-architectures


                //  <package id="TestNDKAsAssetFromSharedLibrary" version="1.0.0.0" targetFramework="net4" userInstalled="true" />
                // X:\jsc.svn\examples\java\android\synergy\OVRVrCubeWorldNativeActivity\OVRVrCubeWorldNativeActivity\ApplicationActivity.cs

                // can we load that native so into a separate process?
                // switch to native and back?
                TestNDKAsAsset.xActivity.stringFromJNI()
            //"Vibrate!"
            );

            b.AtClick(
                delegate
                {
                    var vibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);

                    vibrator.vibrate(600);
                }
            );

            ll.addView(b);



            this.setContentView(sv);


            //this.ShowLongToast("http://my.jsc-solutions.net x");
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );

            //var b2 = new Button(this);
            //b2.setText("The other button!");
            //ll.addView(b2);

            var ipa = Dns.GetHostAddresses(getLocalIpAddress())[0];

            var port = 8080;

            b.WithText(ipa + ":" + port);

            ClassLibrary1.Class1Shared.CreateServer(
                ipa,
                port,
                x =>
                {
                    //b.WithText(x);
                    android.util.Log.wtf("APKWebServer", x);
                }
            ).Start();

            this.setContentView(sv);
        }
Exemplo n.º 14
0
 protected override void onCreate (android.os.Bundle arg0)
 {
     base.onCreate (arg0);
     
     LinearLayout layout = new LinearLayout (this);
     layout.setOrientation (LinearLayout.VERTICAL);
     Button btn = new Button (this);
     btn.setOnClickListener (this);
     btn.setText ("threaD");
     layout.addView (btn);
     
     btn2 = new Button (this);
     btn2.setText ("debug");
     btn2.setOnClickListener (new com.koushikdutta.monojavabridge.android.OnClickListener { OnClick = v =>
     {
         Console.WriteLine ("Foobar");
     } });
     layout.addView (btn2);
     
     tv = new TextView(this);
     layout.addView(tv);
     setContentView (layout);
     
 }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new Button(this).AttachTo(ll);


            var ip = getLocalIpAddress();



            b.WithText("server at " + ip);
            b.AtClick(
                v =>
                {
                    var random = new System.Random();

                    // Error 312 (net::ERR_UNSAFE_PORT): Unknown error.
                    var port = random.Next(1024, 32000);

                    var uri = "http://" + ip;

                    uri += ":";
                    uri += ((object)(port)).ToString();

                    b.setText(uri);

                    Toast.makeText(
                          this,
                          "connect to this web server", 
                          Toast.LENGTH_LONG
                      ).show();

                    var ipa = Dns.GetHostAddresses(ip)[0];


                    Action<string> log = x => Log.wtf("ApplicationActivity", x);

                    // jsc does not import generic param, why?
                    //Action<NetworkStream> AtConnection =
                    NetworkStreamAction AtConnection =
                        s =>
                        {

                            //log("AtConnection");

                            var r = new StreamReader(s);

                            var h0 = r.ReadLine();

                            //log("ReadLine done");

                            var m = new MemoryStream();

                            Action<string> WriteLineASCII = (string e) =>
                            {
                                var x = Encoding.ASCII.GetBytes(e + "\r\n");

                                m.Write(x, 0, x.Length);
                            };

                            WriteLineASCII("HTTP/1.1 200 OK");
                            WriteLineASCII("Content-Type:	text/html; charset=utf-8");
                            //WriteLineASCII("Content-Length: " + data.Length);
                            WriteLineASCII("Connection: close");


                            WriteLineASCII("");
                            WriteLineASCII("");
                            WriteLineASCII("<html>");

                            WriteLineASCII("<body><h1 style='color: red;'>Hello world</h2><h3>jsc</h3><pre>" + h0 + "</pre></body>");

                            WriteLineASCII("</html>");

                            log("write done");

                            var oa = m.ToArray();

                            s.Write(oa, 0, oa.Length);

                            s.Flush();
                            s.Close();
                        };

                    //                    AndroidTcpListenerActivity.AndroidActivity 003e create: AndroidTcpListenerActivity.Activities.ApplicationActivity+<>c__DisplayClass8+<>c__DisplayClassb
                    //switch to STA Exception:
                    //System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The IL Generator cannot be used while there are unclosed exceptions.
                    //   at System.Reflection.Emit.ILGenerator.BakeByteArray()
                    //   at System.Reflection.Emit.MethodBuilder.CreateMethodBodyHelper(ILGenerator il)
                    //   at System.Reflection.Emit.TypeBuilder.CreateTypeNoLock()
                    //   at System.Reflection.Emit.TypeBuilder.CreateType()

                    new Thread(
                            delegate()
                            {
                                var r = new TcpListener(ipa, port);

                                //try
                                //{
                                r.Start();

                                while (true)
                                {
                                    //log("AcceptTcpClient");
                                    var c = r.AcceptTcpClient();
                                    //log("AcceptTcpClient done, GetStream");

                                    var s = c.GetStream();
                                    //log("AcceptTcpClient done, GetStream done");

                                    new Thread(
                                        delegate()
                                        {
                                            //log("before AtConnection");
                                            AtConnection(s);
                                        }
                                    )
                                    {
                                        IsBackground = true,
                                    }.Start();
                                }

                                //}
                                //catch
                                //{
                                //    log("AcceptTcpClient error!");

                                //    throw;
                                //}


                            }
                        )
                    {
                        IsBackground = true,
                    }.Start();
                }
            );

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
        // http://www.codeproject.com/Tips/623446/Style-Any-Activity-as-an-Alert-Dialog-in-Android
        // android:theme="@android:style/Theme.Holo.Dialog"



        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext = this;

            // X:\jsc.svn\examples\java\android\forms\AndroidFormsActivity\AndroidFormsActivity\ApplicationActivity.cs

            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new android.widget.Button(this);

            // jsc is doing the wrong thing here
            var SDK_INT = android.os.Build.VERSION.SDK_INT;

            b.setText("Notify! " + new { SDK_INT, android.os.Build.VERSION.SDK });
            int counter = 0;



            // http://stackoverflow.com/questions/12900795/how-to-get-a-pin-number-password-keyboard-in-android
            //var t = new EditText(this);
            //t.setInputType(android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD);
            //t.setTransformationMethod(android.text.method.PasswordTransformationMethod.getInstance());
            //ll.addView(t);

            // ScriptCoreLib.Ultra ?
            b.AtClick(
                delegate
            {
                counter++;

                // X:\jsc.svn\examples\javascript\android\Test\TestPINDialog\TestPINDialog\ApplicationWebService.cs

                var alertDialog = new AlertDialog.Builder(this);

                alertDialog.setTitle("Hello world");



                alertDialog.setPositiveButton("OK",
                                              new xOnClickListener
                {
                    yield = delegate
                    {
                        b.setText("clicked! " + new { id = Thread.currentThread().getId() });
                    }
                }

                                              );


                var cc = new AndroidFormsActivity.ApplicationControl();


                //ScriptCoreLib.Extensions.Android.AndroidFormsExtensions.AttachTo(
                //    cc,

                // X:\jsc.svn\core\ScriptCoreLibAndroid.Windows.Forms\ScriptCoreLibAndroid.Windows.Forms\Extensions\Android\AndroidFormsExtensions.cs

                __Control _cc = cc;

                _cc.InternalSetContext(this);

                alertDialog.setView(_cc.InternalGetElement());


                // skip icons?
                //alertDialog.setIcon(android.R.drawable.star_off);

                // can we do async yet?
                alertDialog.create().show();
            }
                );

            ll.addView(b);

            this.setContentView(sv);

            // X:\jsc.svn\examples\java\android\HelloOpenGLES20Activity\HelloOpenGLES20Activity\ScriptCoreLib.Android\Shader.cs

            // Error	1	'FormsMessageBox.Activities.ApplicationActivity' does not contain a definition for 'ShowLongToast' and no extension method 'ShowLongToast' accepting a first argument of type 'FormsMessageBox.Activities.ApplicationActivity' could be found (are you missing a using directive or an assembly reference?)	X:\jsc.svn\examples\java\android\FormsMessageBox\FormsMessageBox\ApplicationActivity.cs	80	18	FormsMessageBox
            //this.ShowLongToast("http://jsc-solutions.net");
        }
Exemplo n.º 17
0
        public override void createAndAttachView(int id, FrameLayout frame)
        {
            // http://stackoverflow.com/questions/2761577/android-start-an-intent-into-a-framelayout
            // http://gamma-point.com/content/android-how-have-multiple-activities-under-single-tab-tabactivity#comment-37
            // http://stackoverflow.com/questions/4882776/start-another-activity-inside-the-framelayout-of-tabactivity

            //     Caused by: java.lang.RuntimeException: You must attach your view to the given frame in createAndAttachView()
            //at wei.mark.standout.ui.Window.<init>(Window.java:154)
            //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1078)
            //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
            //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2656)

            var ll = new LinearLayout(
               frame.getContext()
            );

            //ll.setAlpha(0.8f);

            ll.setOrientation(LinearLayout.VERTICAL);

            #region lltab
            var lltab = new LinearLayout(
              frame.getContext()
            );
            lltab.AttachTo(ll);


            var captionpadding = new TextView(frame.getContext());

            captionpadding.setText("    ");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            captionpadding.setShadowLayer(1, 0, 0, Color.WHITE);
            captionpadding.setTextColor(Color.WHITE);
            captionpadding.setBackgroundColor(Color.argb(0x7F, 0, 0, 0));

            captionpadding.AttachTo(lltab);

            var caption = new TextView(frame.getContext());

            caption.setText("XWidgetsWindow");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            caption.setShadowLayer(1, 0, 0, Color.WHITE);
            caption.setTextColor(Color.WHITE);
            caption.setBackgroundColor(Color.argb(0x7F, 0, 0, 0));

            caption.AttachTo(lltab);


            var close = new TextView(frame.getContext());

            close.setText("    x    ");
            // http://stackoverflow.com/questions/3297437/shadow-effect-for-a-text-in-android
            close.setShadowLayer(1, 0, 0, Color.RED);
            close.setTextColor(Color.RED);
            close.setBackgroundColor(Color.argb(0x7F, 0, 0, 0));

            close.AttachTo(lltab);
            close.setClickable(true);

            close.AtClick(
                delegate
                {

                    this.close(id);
                }
            );

            #endregion


            //wei.mark.standout.WindowCache r;

            #region WebView
            var webview = new WebView(frame.getContext());
            //webview.setAlpha(0.8f);

            //frame.startAnimation(new AlphaAnimation(1f, 0.7f));

            //     java.lang.NoSuchMethodError: android.webkit.WebView.setAlpha
            //at PopupWebView.Activities.XWidgetsWindow.createAndAttachView(XWidgetsWindow.java:83)
            //at wei.mark.standout.ui.Window.<init>(Window.java:142)
            //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1026)
            //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
            //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2043)
            //at android.app.ActivityThread.access$2800(ActivityThread.java:117)
            //at android.app.ActivityThread$H.handleMessage(ActivityThread.java:998)
            //at android.os.Handler.dispatchMessage(Handler.java:99)
            //at android.os.Looper.loop(Looper.java:123)
            //at android.app.ActivityThread.main(ActivityThread.java:3687)
            //at java.lang.reflect.Method.invokeNative(Native Method)
            //at java.lang.reflect.Method.invoke(Method.java:507)
            //at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
            //at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
            //at dalvik.system.NativeStart.main(Native Method)


            //getWindow().setFlags(
            //    WindowManager_LayoutParams.FLAG_HARDWARE_ACCELERATED,
            //    WindowManager_LayoutParams.FLAG_HARDWARE_ACCELERATED);

            //setContentView(webview);

            //webview.getSettings().setSupportZoom(true); 
            //webview.getSettings().setLoadsImagesAutomatically(true);
            webview.getSettings().setJavaScriptEnabled(true);
            //webview.getSettings().setBuiltInZoomControls(true);
            //webview.setInitialScale(1);

            webview.setWebViewClient(new MyWebViewClient
            {
                //__this = this 
            });

            webview.setWebChromeClient(
                new MyWebChromeClient
                {
                    yield_title =
                        // implicit version does not work?
                        value =>
                        {
                            caption.setText(value);

                            PersistentNotifications
                                .Where(k => k.id == id)
                                .WithEach(
                                n =>
                                {
                                    n.contentText = value;

                                    n.Notification.setLatestEventInfo(
                                        n.context,
                                        n.contentTitle,
                                        n.contentText,
                                        n.contentIntent
                                    );
                                    n.update();
                                }
                            );
                        }
                }
            );

            //webview.getSettings().setSupportZoom(true);
            //webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);

            //webview.getSettings().setJavaScriptEnabled(true);

            // no flash in emulator?
            // works on my phone!
            // no Flash since android 4.1.0!!!
            //webview.getSettings().setPluginsEnabled(true);
            //webview.getSettings().setPluginState(android.webkit.WebSettings.PluginState.ON);



            // OR, you can also load from an HTML string:
            //var summary = "<html><body>You scored <b>192</b> points.</body></html>";
            //webview.loadData(summary, "text/html", null);
            //Log.i(TAG, "loadUrl");

            //var uri = "http://cubiq.org/dropbox/3dcity/";
            var uri = "http://abstractatech.com";
            webview.loadUrl(uri);
            #endregion

            // http://forum.xda-developers.com/showthread.php?t=1688531

            var rr = new RelativeLayout(frame.getContext());

            rr.setBackgroundColor(Color.argb(0x1F, 255, 255, 255));

            webview.AttachTo(rr);

            var resizer = new Button(frame.getContext());

            resizer.setText(".:");
            //resizer.setAlpha(0.4f);

            resizer.setWidth(96);
            resizer.setHeight(96);
            resizer.setBackgroundColor(Color.argb(0x7F, 255, 255, 255));



            // http://stackoverflow.com/questions/8397152/androidlayout-alignparentbottom-by-code
            // http://stackoverflow.com/questions/8397152/androidlayout-alignparentbottom-by-code




            resizer.AttachTo(rr);

            RelativeLayout.LayoutParams p = new RelativeLayout.LayoutParams(
               RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT
             );

            //400, 250,
            p.setMargins(400 - 64, 250 - 64 - 32, 0, 0);
            resizer.setLayoutParams(p);



            resizer.setOnTouchListener(
                new __OnTouchListener
                {
                    yield = (view, e) =>
                    {
                        var ww = getWindow(id);

                        // handle dragging to move
                        var consumed = this.onTouchHandleResize(id,
                            ww,
                            view,
                            e
                        );

                        {
                            p.setMargins(ww.getWidth() - 64 + 10, ww.getHeight() - 64 - 20, 0, 0);
                            resizer.setLayoutParams(p);
                        }
                        return consumed;
                    }
                }
            );

            rr.AttachTo(ll);
            ll.AttachTo(frame);

            {
                //Caused by: java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to wei.mark.standout.StandOutWindow$StandOutLayoutParams
                //at wei.mark.example.XWidgetsWindow.createAndAttachView(XWidgetsWindow.java:101)
                //at wei.mark.standout.ui.Window.<init>(Window.java:150)
                //at wei.mark.standout.StandOutWindow.show(StandOutWindow.java:1078)
                //at wei.mark.standout.StandOutWindow.onStartCommand(StandOutWindow.java:381)
                //at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2656)

                //p.setMargins(ww.getWidth() - 64, ww.getHeight() - 64 - 32, 0, 0);
                //resizer.setLayoutParams(p);
            }
        }
        // http://stackoverflow.com/questions/17513502/support-for-multi-window-app-development

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this);

            b.setText("Vibrate!");

            b.AtClick(
                async delegate
                {
                    var vibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);

                    vibrator.vibrate(600);

                    // or jump to laptop pointerlock?

                    SwitchToCompiler.Invoke(
                        delegate
                        {
                            // did we jump back to compiler?
                            // UDP?
                            // RSA?


                        }
                    );

                    // or

                    //        [javac] W:\src\ADBSwitchToCompiler\Activities\ApplicationActivity___onCreate_b__0_0_d__MoveNext_0600000f.java:48: error: cannot find symbol
                    //[javac]         ApplicationActivity___onCreate_b__0_0_d__MoveNext_0600000f.__workflow(next_0600000f0, ref_awaiter1, ref_compiler2, ref_create_b__0_0_d3);
                    //[javac]                                                                                                                            ^

                    // roslyn wont like it?
                    await default(SwitchToCompiler);
                    // X:\jsc.svn\examples\javascript\chrome\extensions\ChromeExtensionHopToTab\ChromeExtensionHopToTab\Application.cs

                    // did we jump back to compiler?
                    // UDP?
                    // RSA?


                    Console.WriteLine("record screen");

                    Console.WriteLine("pull");

                    // https://developers.google.com/youtube/v3/code_samples/dotnet

                }
            );

            ll.addView(b);



            this.setContentView(sv);


            //this.ShowLongToast("http://my.jsc-solutions.net x");
        }
        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            ScrollView sv = new ScrollView(this);

            LinearLayout ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);


            Button b = new Button(this);

            b.setText("AlertDialog! " + new { id = Thread.currentThread().getId() });
            int counter = 0;

            // ScriptCoreLib.Ultra ?
            b.AtClick(
                delegate
            {
                counter++;

                // http://www.tomswebdesign.net/Articles/Android/number-pad-input-class.html
                // https://android.googlesource.com/platform/frameworks/base/+/b896b9f/packages/Keyguard/src/com/android/keyguard/KeyguardSimPinView.java
                // http://xmlstackoverflow.blogspot.com/2014/07/how-to-use-alertdialog-to-prompt-for-pin.html
                // http://incidencias-ctt.administracionelectronica.gob.es/websvn/filedetails.php?repname=clienteafirma&path=%2Fproject%2Fafirma-mobile%2Fafirma-android%2Ftrunk%2Fafirma-ui-android%2Fsrc%2Fes%2Fgob%2Fafirma%2Fandroid%2Fgui%2FPinDialog.java&peg=4040

                // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\ApplicationActivity.cs
                // X:\jsc.svn\examples\java\android\Test\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs
                AlertDialog alertDialog = new AlertDialog.Builder(this).create();

                alertDialog.setTitle("Reset...");
                alertDialog.setMessage("Are you sure?");
                alertDialog.setButton("OK",
                    new xOnClickListener
                {
                    yield = delegate
                    {
                        b.setText("clicked! " + new { id = Thread.currentThread().getId() });
                    }
                }

                    );

                // skip icons?
                //alertDialog.setIcon(android.R.drawable.star_off);

                // can we do async yet?
                alertDialog.show();


            }
            );

            ll.addView(b);

            this.setContentView(sv);

            // X:\jsc.svn\examples\java\android\HelloOpenGLES20Activity\HelloOpenGLES20Activity\ScriptCoreLib.Android\Shader.cs

            // Error	1	'TestAlertDialog.Activities.ApplicationActivity' does not contain a definition for 'ShowLongToast' and no extension method 'ShowLongToast' accepting a first argument of type 'TestAlertDialog.Activities.ApplicationActivity' could be found (are you missing a using directive or an assembly reference?)	X:\jsc.svn\examples\java\android\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs	80	18	TestAlertDialog
            //this.ShowLongToast("http://jsc-solutions.net");
            //this.ShowToast("http://jsc-solutions.net");


        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var activity = this;
            // http://stackoverflow.com/questions/11425020/actionbar-in-a-dialogfragment
            //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
            //activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_DIM_BEHIND, WindowManager_LayoutParams.FLAG_DIM_BEHIND);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //var @params = activity.getWindow().getAttributes();
            ////@params.height = WindowManager_LayoutParams.FILL_PARENT;
            ////@params.width = 850; //fixed width
            ////@params.height = 450; //fixed width
            //@params.alpha = 1.0f;
            //@params.dimAmount = 0.5f;
            //activity.getWindow().setAttributes(@params);
            //activity.getWindow().setLayout(850, 850);
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);


            // https://stackoverflow.com/questions/1898886/removing-an-activity-from-the-history-stack

            b.WithText("start secondary");
            b.AtClick(
                v =>
                {
                    foo = "hi";

                    Intent intent = new Intent(this, typeof(SecondaryActivity).ToClass());
                    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
                    //intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                    startActivity(intent);
                }
            );

            this.AtPause += delegate { b.setText("AtPause"); };
            this.AtResume += delegate { b.setText("AtResume"); };


            AtPrepareOptions +=
                value =>
                {
                    value.clear();

                    var item1 = value.add(
                         (java.lang.CharSequence)(object)"http://abstractatech.com"
                    );



                    item1.setIcon(android.R.drawable.ic_menu_view);

                    var item2 = value.add(
                        (java.lang.CharSequence)(object)"http://jsc-solutions.net"
                    );

                    //item2.setIcon(android.R.drawable.ic_menu_edit);
                    item2.setIcon(android.R.drawable.ic_menu_view);

                    var i = new Intent(Intent.ACTION_VIEW,
                        android.net.Uri.parse("http://jsc-solutions.net")
                    );

                    // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/
                    var ic = Intent.createChooser(i, "http://jsc-solutions.net");


                    item2.setIntent(
                        ic
                    );
                };

            AtOption +=
                item =>
                {

                    //b.WithText("menu was clicked!" + (string)(object)item.getTitle());
                    b.WithText("menu was clicked!" + new { item });
                };

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);



            vConfigurationChanged = e =>
            {
                var orientation = getScreenOrientation();

                var SystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();

                b2.setText(
                    new
                    {
                        orientation,
                        SystemUiVisibility
                    }.ToString()
                );


                if (orientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                    hideSystemUI();
                }
                else
                {
                    showSystemUI();
                }
            };

            vConfigurationChanged(null);
        }
            public android.view.View createTabContent(string value)
            {
                ScrollView sv = new ScrollView(c);

                LinearLayout ll = new LinearLayout(c);

                ll.setOrientation(LinearLayout.VERTICAL);

                sv.addView(ll);


                Button b = new Button(c);

                b.setText("Yay. This almost works!");

                ll.addView(b);





                return sv;
            }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var activity = this;
            // http://stackoverflow.com/questions/11425020/actionbar-in-a-dialogfragment
            //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
            //activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_DIM_BEHIND, WindowManager_LayoutParams.FLAG_DIM_BEHIND);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //var @params = activity.getWindow().getAttributes();
            ////@params.height = WindowManager_LayoutParams.FILL_PARENT;
            ////@params.width = 850; //fixed width
            ////@params.height = 450; //fixed width
            //@params.alpha = 1.0f;
            //@params.dimAmount = 0.5f;
            //activity.getWindow().setAttributes(@params);
            //activity.getWindow().setLayout(850, 850);
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );


            AtPrepareOptions +=
                value =>
                {
                    value.clear();

                    var item1 = value.add(
                         (java.lang.CharSequence)(object)"http://abstractatech.com"
                    );



                    item1.setIcon(android.R.drawable.ic_menu_view);

                    var item2 = value.add(
                        (java.lang.CharSequence)(object)"http://jsc-solutions.net"
                    );

                    //item2.setIcon(android.R.drawable.ic_menu_edit);
                    item2.setIcon(android.R.drawable.ic_menu_view);

                    var i = new Intent(Intent.ACTION_VIEW,
                        android.net.Uri.parse("http://jsc-solutions.net")
                    );

                    // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/
                    var ic = Intent.createChooser(i, "http://jsc-solutions.net");


                    item2.setIntent(
                        ic
                    );
                };

            AtOption +=
                item =>
                {

                    //b.WithText("menu was clicked!" + (string)(object)item.getTitle());
                    b.WithText("menu was clicked!" + new { item });
                };

            var b2 = new Button(this);
            b2.setText("The other button!");
            ll.addView(b2);

            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var file1 = "http://a.tumblr.com/tumblr_m8ueqqpyyy1rs64dko1.mp3";
            var name1 = "E43 Understanding the Dangers of Ego-Depletion by Tim";

            base.onCreate(savedInstanceState);

            var downloadManager   = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
            var preferenceManager = PreferenceManager.getDefaultSharedPreferences(this);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new android.widget.Button(this).AttachTo(ll);

            downloadReceiver = new MyDownloadReceiver
            {
            };

            //            O:\src\AndroidDownloadManagerActivity\Activities\ApplicationActivity___c__DisplayClass2___c__DisplayClass4.java:60: cannot find symbol
            //symbol  : class Button
            //location: class AndroidDownloadManagerActivity.Activities.ApplicationActivity___c__DisplayClass2___c__DisplayClass4
            //                    ViewExtensions.<Button>WithText(this.CS___8__locals3.b, "Download " + this.CS___8__locals3.name1);
            //                                    ^

            b.WithText("Download " + name1);
            b.AtClick(
                v =>
            {
                b.setText("Downloading...");
                b.setEnabled(false);

                var downloadUri = android.net.Uri.parse(file1);

                // http://developer.android.com/reference/android/app/DownloadManager.Request.html
                var request = new DownloadManager.Request(downloadUri);

                request.setTitle("idea-remixer");
                request.setDescription(name1);

                // W/DownloadManager(15222): Aborting request for download 166: while trying to execute request:
                // java.net.UnknownHostException: Unable to resolve host "a.tumblr.com":
                // No address associated with hostname
                var id = downloadManager.enqueue(request);

                Toast.makeText(this, new { id, downloadUri }.ToString(), Toast.LENGTH_LONG).show();

                //Save the request id

                //var PrefEdit = preferenceManager.edit();
                //PrefEdit.putLong(strPref_Download_ID, id);
                //PrefEdit.commit();

                downloadReceiver.AtReceive = delegate
                {
                    DownloadManager.Query query = new DownloadManager.Query();
                    //query.setFilterById(preferenceManager.getLong(strPref_Download_ID, 0));
                    // http://developer.android.com/reference/android/app/DownloadManager.Query.html#setFilterById(long...)
                    query.setFilterById(new[] { id });
                    Cursor cursor = downloadManager.query(query);

                    if (cursor.moveToFirst())
                    {
                        int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
                        int status      = cursor.getInt(columnIndex);

                        if (status == DownloadManager.STATUS_FAILED)
                        {
                            Toast.makeText(this, new { id, status }.ToString(), Toast.LENGTH_LONG).show();

                            b.WithText("(failed) Download " + name1);
                            b.setEnabled(true);
                        }
                        else if (status == DownloadManager.STATUS_SUCCESSFUL)
                        {
                            //Retrieve the saved request id
                            //long downloadID = preferenceManager.getLong(strPref_Download_ID, 0);
                            var uri = downloadManager.getUriForDownloadedFile(id);


                            Toast.makeText(this, new { id, uri }.ToString(), Toast.LENGTH_LONG).show();

                            // jsc ignores this type in import?
                            Button __ref0;

                            b.WithText("Download " + name1);
                            b.setEnabled(true);

                            //ParcelFileDescriptor file;
                            //try
                            //{
                            //    file = downloadManager.openDownloadedFile(downloadID);
                            //    //FileInputStream fileInputStream       = new ParcelFileDescriptor.AutoCloseInputStream(file);
                            //    //Bitmap bm = BitmapFactory.decodeStream(fileInputStream);
                            //    //image.setImageBitmap(bm);
                            //}
                            //catch // (FileNotFoundException e)
                            //{      // TODO Auto-generated catch block
                            //    //e.printStackTrace();
                            //    throw;
                            //}
                        }
                    }
                };
            }
                );


            this.setContentView(sv);
        }
        // "x:\util\android-sdk-windows\platform-tools\adb.exe"  tcpip 5555
        // restarting in TCP mode port: 5555

        // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect 192.168.1.126:5555
        // connected to 192.168.1.126:5555

        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150513

        // lets verify this thing . deploy over wifi.

        //C:\Windows\system32> "x:\util\android-sdk-windows\platform-tools\adb.exe" shell netcfg
        //wlan0    UP                               192.168.1.126/24  0x00001043 e8:50:8b:7d:27:7c

        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);

            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );


            this.setContentView(sv);



            var s = new SemaphoreSlim(0);

            //java.lang.Object, rt
            //enter async { ManagedThreadId = 1 }
            //awaiting for SemaphoreSlim{ ManagedThreadId = 1 }
            //after delay{ ManagedThreadId = 8 }
            //http://127.0.0.1:8080
            //{ fileName = http://127.0.0.1:8080 }
            //enter catch { mname = <0032> nop.try } ClauseCatchLocal:
            //{ Message = , StackTrace = java.lang.RuntimeException
            //        at ScriptCoreLibJava.BCLImplementation.System.Net.Sockets.__TcpListener.AcceptTcpClientAsync(__TcpListener.java:131)

            new { }.With(
                async delegate
                {
                    //System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                    //enter async { ManagedThreadId = 1 }
                    //awaiting for SemaphoreSlim{ ManagedThreadId = 1 }
                    //after delay{ ManagedThreadId = 4 }
                    //http://127.0.0.1:8080
                    //awaiting for SemaphoreSlim. done.{ ManagedThreadId = 1 }
                    //--
                    //accept { c = System.Net.Sockets.TcpClient, ManagedThreadId = 6 }
                    //System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                    //accept { c = System.Net.Sockets.TcpClient, ManagedThreadId = 8 }
                    //{ ManagedThreadId = 6, input = GET / HTTP/1.1


                    Console.WriteLine("enter async " + new { Thread.CurrentThread.ManagedThreadId });

                    // X:\jsc.svn\examples\javascript\chrome\apps\ChromeTCPServerAsync\ChromeTCPServerAsync\Application.cs
                    await Task.Delay(100);

                    Console.WriteLine("after delay" + new { Thread.CurrentThread.ManagedThreadId });

                    // Additional information: Only one usage of each socket address (protocol/network address/port) is normally permitted
                    // close the other server!
                    var l = new TcpListener(IPAddress.Any, 8080);

                    l.Start();


                    var href =
                        "http://127.0.0.1:8080";

                    Console.WriteLine(
                        href
                    );



                    this.runOnUiThread(
                        delegate
                        {
                            var i = new Intent(Intent.ACTION_VIEW,
                               android.net.Uri.parse(href)
                           );

                            // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/
                            var ic = Intent.createChooser(i, href);


                            this.startActivity(ic);
                        }
                    );



                    new { }.With(
                        async delegate
                        {
                            while (true)
                            {
                                var c = await l.AcceptTcpClientAsync();

                                Console.WriteLine("accept " + new { c, Thread.CurrentThread.ManagedThreadId });

                                yield(c);
                            }
                        }
                    );

                    // jump back to main thread..
                    s.Release();
                }
            );
        }
        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201412/20141207
        // how can we shot this from NDK?
        // what if we are in vr?
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150607-1/surfaceview


        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);

            sv.addView(ll);


            int counter = 0;

            Action yield = delegate
            {
                counter++;
                var nm = (NotificationManager)this.getSystemService(Activity.NOTIFICATION_SERVICE);


                // see http://developer.android.com/reference/android/app/Notification.html
                var notification = new Notification(
                    android.R.drawable.stat_notify_sync,
                    "not used?",

                    0
                    //java.lang.System.currentTimeMillis()
                );

                notification.defaults |= Notification.DEFAULT_SOUND;
                //notification.vibrate = new long[] { 100, 200, 200, 200, 200, 200, 1000, 200, 200, 200, 1000, 200 };
                notification.vibrate = new long[] { 1000 };

                //             script: error JSC1000: Java : unable to emit newarr at 'AndroidNotificationActivity.Activities.ApplicationActivity+<>c__DisplayClass2.<onCreate>b__0'#004c: System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                //at jsc.Languages.Java.JavaCompiler.<>c__DisplayClass1a7.<>c__DisplayClass1be.<CreateInstructionHandlers>b__162() in x:\jsc.internal.git\compiler\jsc\Languages\Java\JavaCompiler.OpCodes.cs:line 1720

                var notificationIntent = new Intent(this, typeof(ApplicationActivity).ToClass());
                var contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);


                notification.setLatestEventInfo(
                    this,
                    "Visible in Gear VR!",
                    "yet it wont vibrate",
                    contentIntent);

                //notification.defaults |= Notification.DEFAULT_VIBRATE;
                //notification.defaults |= Notification.DEFAULT_LIGHTS;
                // http://androiddrawableexplorer.appspot.com/
                nm.notify(counter, notification);
            };


            var b = new Button(this);

            b.setText("Notify!");

            // ScriptCoreLib.Ultra ?
            b.AtClick(
                delegate
                {
                    yield();
                }
            );

            ll.addView(b);

            this.setContentView(sv);

            // X:\jsc.svn\examples\java\android\HelloOpenGLES20Activity\HelloOpenGLES20Activity\ScriptCoreLib.Android\Shader.cs

            // Error	1	'AndroidNotificationActivity.Activities.ApplicationActivity' does not contain a definition for 'ShowLongToast' and no extension method 'ShowLongToast' accepting a first argument of type 'AndroidNotificationActivity.Activities.ApplicationActivity' could be found (are you missing a using directive or an assembly reference?)	X:\jsc.svn\examples\java\android\AndroidNotificationActivity\AndroidNotificationActivity\ApplicationActivity.cs	80	18	AndroidNotificationActivity
            //this.ShowLongToast("http://jsc-solutions.net");
            this.ShowToast("http://jsc-solutions.net");

            yield();

        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);

            var goo = new foo.Goo();

            //Activator.CreateInstance<

            //var goo = (foo.Goo)Activator.CreateInstance(
            //    typeof(foo.Goo)
            //);

            //E/AndroidRuntime(32112): Caused by: java.lang.RuntimeException
            //E/AndroidRuntime(32112):        at foo.Bar.GetBarString(Bar.java:29)
            //E/AndroidRuntime(32112):        at foo.Goo.GetString(Goo.java:9)
            //E/AndroidRuntime(32112):        at TestJavaNativesOverride.Activities.ApplicationActivity.onCreate(ApplicationActivity.java:69)

            b.WithText(goo.GetString());
            b.AtClick(
                v =>
                {
                    b.setText(
                         new assets::foo.Bar().GetBarString()
                    );
                }
            );


            this.setContentView(sv);



        }
        static __InitializeAndroidActivity()
        {
            Console.WriteLine("StaticInvoke");

            //  Exception Ljava/lang/RuntimeException; thrown while initializing LTryHideActionbarExperiment/StaticInvoke;
            try
            {


                // https://groups.google.com/forum/?fromgroups=#!topic/android-developers/suLMCWiG0D8
                var c = ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext;


                (ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext as ScriptCoreLib.Android.CoreAndroidWebServiceActivity).runOnUiThread(
                    a =>
                    {
                        //var c = ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext;



                        // http://stackoverflow.com/questions/4451641/change-android-layout-programatically

                        var sv = new ScrollView(a);
                        var ll = new LinearLayout(a);
                        //ll.setOrientation(LinearLayout.VERTICAL);
                        sv.addView(ll);

                        var b = new Button(a).AttachTo(ll);



                        b.WithText("before AtClick");
                        b.AtClick(
                            v =>
                            {
                                b.setText("AtClick");
                            }
                        );

                        var b2 = new Button(a);
                        b2.setText("The other button!");
                        ll.addView(b2);


                        //Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f050002
                        //       at android.content.res.Resources.getText(Resources.java:230)
                        //       at android.content.res.Resources.getString(Resources.java:314)
                        //       at com.facebook.widget.LoginButton.setButtonText(LoginButton.java:532)
                        //       at com.facebook.widget.LoginButton.finishInit(LoginButton.java:472)
                        //       at com.facebook.widget.LoginButton.<init>(LoginButton.java:189)

                        var login = new LoginButton(a);

                        // You have disabled Facebook Login in your app, but you must still specify Package Name or Key Hashes.
                        //login.loginText = "loginText";
                        login.setApplicationId("625051627510580");

                        //                        FATAL EXCEPTION: main
                        //java.lang.NullPointerException: Argument 'applicationId' cannot be null
                        //       at com.facebook.internal.Validate.notNull(Validate.java:29)
                        //       at com.facebook.Session.<init>(Session.java:224)
                        //       at com.facebook.Session.<init>(Session.java:213)
                        //       at com.facebook.Session$Builder.build(Session.java:1454)
                        //       at com.facebook.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:621)


                        //                        FATAL EXCEPTION: main
                        //com.facebook.FacebookException: Cannot use SessionLoginBehavior SSO_WITH_FALLBACK when com.facebook.LoginActivity is not declared as an activity in AndroidManifest.xml
                        //       at com.facebook.Session.validateLoginBehavior(Session.java:992)
                        //       at com.facebook.Session.open(Session.java:915)
                        //       at com.facebook.Session.openForRead(Session.java:385)
                        //       at com.facebook.widget.LoginButton$LoginClickListener.onClick(LoginButton.java:641)

                        //                 Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030001
                        //at android.content.res.Resources.getValue(Resources.java:1014)
                        //at android.content.res.Resources.loadXmlResourceParser(Resources.java:2139)
                        //at android.content.res.Resources.getLayout(Resources.java:853)
                        //at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
                        //at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                        //at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
                        //at android.app.Activity.setContentView(Activity.java:1881)
                        //at com.facebook.LoginActivity.onCreate(LoginActivity.java:55)

                        login.setSessionStatusCallback(
                            new XStatusCallback
                            {
                                yield = (arg0, arg1, arg2) =>
                                {
                                    var AccessToken = arg0.getAccessToken();
                                    Console.WriteLine(new { AccessToken, arg0, arg1, arg2 });

                                }
                            }
                        );

                        login.setUserInfoChangedCallback(
                            new XUserInfoChangedCallback
                            {

                                yield = u =>
                                {
                                    var id = u.getId();
                                    var name = u.getName();

                                    Console.WriteLine(new { name, id });

                                    b2.WithText(new { name, id }.ToString());
                                }

                            }
                        );

                        login.AttachTo(ll);

                        a.setContentView(sv);
                    }
                );
            }
            catch (Exception ex)
            {
                Console.WriteLine("error: " + new { ex.Message, ex.StackTrace });
            }
        }
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151212/androidudpclipboard
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20160101/ovrwindwheelndk

        //        connect s6 via usb .
        // turn on wifi!
        // kill adb

        //"x:\util\android-sdk-windows\platform-tools\adb.exe"  tcpip 5555
        // restarting in TCP mode port: 5555

        //13: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        //    inet 192.168.1.126/24 brd 192.168.1.255 scope global wlan0
        //       valid_lft forever preferred_lft forever

        // on red
        // "x:\util\android-sdk-windows\platform-tools\adb.exe" connect  192.168.1.126:5555
        // connected to 192.168.1.126:5555



        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151121
        // http://stackoverflow.com/questions/17513502/support-for-multi-window-app-development

        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            // http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this);

            b.setText("Vibrate!");

            var sw = Stopwatch.StartNew();



            Action cleanup = delegate { };

            Notification reuse = null;
            var notificationIntent = new Intent(this, typeof(ApplicationActivity).ToClass());
            var contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

            Action<string> SetClipboard = value =>
            {
                Console.WriteLine("SetClipboard " + new { value });

                this.runOnUiThread(
                    delegate
                    {
                        cleanup();

                        b.setText(value);




                        if (reuse != null)
                        {
                            reuse.setLatestEventInfo(
                                 this,
                                 contentTitle: value,
                                 contentText: "",
                                 contentIntent: contentIntent);

                            return;
                        }

                        var xNotificationManager = (NotificationManager)this.getSystemService(Activity.NOTIFICATION_SERVICE);

                        // see http://developer.android.com/reference/android/app/Notification.html
                        var xNotification = new Notification(
                            //android.R.drawable.ic_dialog_alert,
                            android.R.drawable.ic_menu_view,
                            //tickerText: "not used?",
                            tickerText: value,


                            when: 0
                            //java.lang.System.currentTimeMillis()
                        );

                        //notification.defaults |= Notification.DEFAULT_SOUND;



                        // flags = Notification.FLAG_ONGOING_EVENT 

                        var FLAG_ONGOING_EVENT = 0x00000002;
                        //notification.flags |= Notification.FLAG_ONGOING_EVENT;
                        //xNotification.flags |= FLAG_ONGOING_EVENT;

                        xNotification.setLatestEventInfo(
                            this,
                            contentTitle: value,
                            contentText: "",
                            contentIntent: contentIntent);

                        //notification.defaults |= Notification.DEFAULT_VIBRATE;
                        //notification.defaults |= Notification.DEFAULT_LIGHTS;
                        // http://androiddrawableexplorer.appspot.com/

                        var id = (int)sw.ElapsedMilliseconds;

                        xNotificationManager.notify(id, xNotification);

                        var xVibrator = (Vibrator)this.getSystemService(Context.VIBRATOR_SERVICE);
                        xVibrator.vibrate(600);



                        #region setPrimaryClip
                        android.content.ClipboardManager clipboard = (android.content.ClipboardManager)getSystemService(CLIPBOARD_SERVICE);
                        ClipData clip = ClipData.newPlainText("label", value);
                        clipboard.setPrimaryClip(clip);
                        #endregion

                        reuse = xNotification;


                        cleanup += delegate
                        {
                            // https://developer.android.com/reference/android/app/Notification.html

                            if (xNotification == null)
                                return;

                            xNotificationManager.cancel(id);
                        };
                    }
                );
            };


            b.AtClick(
                delegate
                {
                    SetClipboard("hello");
                }
            );



            // Z:\jsc.svn\examples\c\android\Test\TestNDKUDP\TestNDKUDP\xNativeActivity.cs

            #region lets listen to incoming udp
            // could we define our chrome app inline in here?
            // or in a chrome app. could we define the android app inline?
            #region ReceiveAsync
            Action<IPAddress> f = async nic =>
            {
                b.setText("awaiting at " + nic);


                WifiManager wifi = (WifiManager)this.getSystemService(Context.WIFI_SERVICE);
                var lo = wifi.createMulticastLock("udp:49814");
                lo.acquire();

                // Z:\jsc.svn\examples\java\android\AndroidUDPClipboard\ApplicationActivity.cs
                // X:\jsc.svn\examples\java\android\forms\FormsUDPJoinGroup\FormsUDPJoinGroup\ApplicationControl.cs
                // X:\jsc.svn\examples\java\android\LANBroadcastListener\LANBroadcastListener\ApplicationActivity.cs
                var uu = new UdpClient(49814);
                uu.JoinMulticastGroup(IPAddress.Parse("239.1.2.3"), nic);
                while (true)
                {
                    // cannot get data from RED?
                    var x = await uu.ReceiveAsync(); // did we jump to ui thread?
                    //Console.WriteLine("ReceiveAsync done " + Encoding.UTF8.GetString(x.Buffer));
                    var data = Encoding.UTF8.GetString(x.Buffer);



                    // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150704
                    // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150704/mousedown
                    SetClipboard(data);
                }
            };

            // WithEach defined at?
            NetworkInterface.GetAllNetworkInterfaces().WithEach(
                n =>
                {
                    // X:\jsc.svn\examples\java\android\forms\FormsUDPJoinGroup\FormsUDPJoinGroup\ApplicationControl.cs
                    // X:\jsc.svn\core\ScriptCoreLibJava\BCLImplementation\System\Net\NetworkInformation\NetworkInterface.cs

                    var IPProperties = n.GetIPProperties();
                    var PhysicalAddress = n.GetPhysicalAddress();



                    foreach (var ip in IPProperties.UnicastAddresses)
                    {
                        // ipv4
                        if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
                        {
                            if (!IPAddress.IsLoopback(ip.Address))
                                if (n.SupportsMulticast)
                                    f(ip.Address);
                        }
                    }




                }
            );
            #endregion


            #endregion

            // jsc could pass this ptr to ctor for context..
            var t = new EditText(this) { };

            t.AttachTo(ll);

            ll.addView(b);



            this.setContentView(sv);


            //this.ShowLongToast("http://my.jsc-solutions.net x");
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var b2 = new Button(this);
            {
                var ll = new LinearLayout(this);
                //ll.setOrientation(LinearLayout.VERTICAL);
                sv.addView(ll);

                var b1 = new Button(this).AttachTo(ll);



                b1.WithText("LANBroadcastListener createMulticastLock");


                var c = 0;

                b1.AtClick(
                    v =>
                    {
                        //                 server error { Message = , StackTrace = android.os.NetworkOnMainThreadException
                        //at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
                        //at libcore.io.BlockGuardOs.sendto(BlockGuardOs.java:175)
                        //at libcore.io.IoBridge.sendto(IoBridge.java:473)
                        //at java.net.PlainDatagramSocketImpl.send(PlainDatagramSocketImpl.java:182)
                        //at java.net.DatagramSocket.send(DatagramSocket.java:284)

                        new Thread(
                            delegate()
                            {

                                try
                                {
                                    var socket = new DatagramSocket(); //construct a datagram socket and binds it to the available port and the localhos

                                    c++;

                                    var b = Encoding.UTF8.GetBytes(c + " hi from jvm!");    //creates a variable b of type byte
                                    var dgram = new DatagramPacket((sbyte[])(object)b, b.Length, InetAddress.getByName("239.1.2.3"), 40404);//sends the packet details, length of the packet,destination address and the port number as parameters to the DatagramPacket  
                                    //dgram.setData(b);
                                    //System.Console.WriteLine(
                                    //    "Sending " + b.Length + " bytes to " + dgram.getAddress() + ":" + dgram.getPort());//standard error output stream
                                    socket.send(dgram); //send the datagram packet from this port
                                }
                                catch (Exception ex)
                                {
                                    System.Console.WriteLine("server error " + new { ex.Message, ex.StackTrace });
                                }

                            }
                                )
                               {

                                   Name = "sender"
                               }.Start();
                    }
                );

                b2.setText("The other button!");
                ll.addView(b2);

                this.setContentView(sv);
            }


            // http://www.zzzxo.com/q/answers-android-device-not-receiving-multicast-package-13221736.html



            new Thread(
                delegate()
                {
                    // http://stackoverflow.com/questions/12610415/multicast-receiver-malfunction
                    // http://answers.unity3d.com/questions/250732/android-build-is-not-receiving-udp-broadcasts.html

                    // Acquire multicast lock
                    wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
                    multicastLock = wifi.createMulticastLock("multicastLock");
                    //multicastLock.setReferenceCounted(true);
                    multicastLock.acquire();

                    System.Console.WriteLine("LANBroadcastListener ready...");
                    try
                    {
                        byte[] b = new byte[0x100];

                        // https://code.google.com/p/android/issues/detail?id=40003

                        var port = 40404;

                        MulticastSocket socket = new MulticastSocket(port); // must bind receive side
                        socket.setBroadcast(true);
                        socket.setReuseAddress(true);
                        socket.setTimeToLive(30);
                        socket.setReceiveBufferSize(0x100);
                        
                        // https://code.google.com/p/android/issues/detail?id=40003
                        // http://stackoverflow.com/questions/6550618/multicast-support-on-android-in-hotspot-tethering-mode
                        // http://www.massapi.com/class/java/net/InetSocketAddress.java.html
                        // http://www.javadocexamples.com/java/net/MulticastSocket/joinGroup(SocketAddress%20mcastaddr,NetworkInterface%20netIf).html
                        // http://grokbase.com/t/hadoop/common-issues/117jsjk8d7/jira-created-hadoop-7472-rpc-client-should-deal-with-the-ip-address-changes

                        var group = InetAddress.getByName("239.1.2.3");
                        var groupSockAddr = new InetSocketAddress(group, port);

                        // what lan interfaces do we have?
                        socket.joinGroup(groupSockAddr,
                            NetworkInterface.getByName("wlan0")
                        );

                        System.Console.WriteLine("LANBroadcastListener joinGroup...");
                        while (true)
                        {
                            DatagramPacket dgram = new DatagramPacket((sbyte[])(object)b, b.Length);
                            socket.receive(dgram); // blocks until a datagram is received

                            var bytes = new MemoryStream((byte[])(object)dgram.getData(), 0, dgram.getLength());


                            var listen = Encoding.UTF8.GetString(bytes.ToArray());

                            System.Console.WriteLine("Received "
                                + dgram.getLength()
                                + " bytes from " + dgram.getAddress());
                            //dgram.setLength(b.Length); // must reset length field!s



                        }
                    }
                    catch
                    {
                        System.Console.WriteLine("client error");
                    }
                }
            )
            {

                Name = "client"
            }.Start();

        }
            public android.view.View createTabContent(string value)
            {
                ScrollView sv = new ScrollView(c);

                LinearLayout ll = new LinearLayout(c);

                ll.setOrientation(LinearLayout.VERTICAL);

                sv.addView(ll);


                Button b = new Button(c);

                b.setText("I don't do anything, but I was added dynamically. :)");

                ll.addView(b);




          
                return sv;
            }
        protected override void onCreate(Bundle savedInstanceState)
        {
            var file1 = "http://a.tumblr.com/tumblr_m8ueqqpyyy1rs64dko1.mp3";
            var name1 = "E43 Understanding the Dangers of Ego-Depletion by Tim";

            base.onCreate(savedInstanceState);

            var downloadManager = (DownloadManager)getSystemService(DOWNLOAD_SERVICE);
            var preferenceManager = PreferenceManager.getDefaultSharedPreferences(this);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            //ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new android.widget.Button(this).AttachTo(ll);

            downloadReceiver = new MyDownloadReceiver
            {

            };

            //            O:\src\AndroidDownloadManagerActivity\Activities\ApplicationActivity___c__DisplayClass2___c__DisplayClass4.java:60: cannot find symbol
            //symbol  : class Button
            //location: class AndroidDownloadManagerActivity.Activities.ApplicationActivity___c__DisplayClass2___c__DisplayClass4
            //                    ViewExtensions.<Button>WithText(this.CS___8__locals3.b, "Download " + this.CS___8__locals3.name1);
            //                                    ^

            b.WithText("Download " + name1);
            b.AtClick(
                v =>
                {

                    b.setText("Downloading...");
                    b.setEnabled(false);

                    var downloadUri = android.net.Uri.parse(file1);

                    // http://developer.android.com/reference/android/app/DownloadManager.Request.html
                    var request = new DownloadManager.Request(downloadUri);

                    request.setTitle("idea-remixer");
                    request.setDescription(name1);

                    // W/DownloadManager(15222): Aborting request for download 166: while trying to execute request: 
                    // java.net.UnknownHostException: Unable to resolve host "a.tumblr.com": 
                    // No address associated with hostname
                    var id = downloadManager.enqueue(request);

                    Toast.makeText(this, new { id, downloadUri }.ToString(), Toast.LENGTH_LONG).show();

                    //Save the request id   

                    //var PrefEdit = preferenceManager.edit();
                    //PrefEdit.putLong(strPref_Download_ID, id);
                    //PrefEdit.commit();

                    downloadReceiver.AtReceive = delegate
                    {
                        DownloadManager.Query query = new DownloadManager.Query();
                        //query.setFilterById(preferenceManager.getLong(strPref_Download_ID, 0));
                        // http://developer.android.com/reference/android/app/DownloadManager.Query.html#setFilterById(long...)
                        query.setFilterById(new[] { id });
                        Cursor cursor = downloadManager.query(query);

                        if (cursor.moveToFirst())
                        {
                            int columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS);
                            int status = cursor.getInt(columnIndex);

                            if (status == DownloadManager.STATUS_FAILED)
                            {
                                Toast.makeText(this, new { id, status }.ToString(), Toast.LENGTH_LONG).show();

                                b.WithText("(failed) Download " + name1);
                                b.setEnabled(true);
                            }
                            else if (status == DownloadManager.STATUS_SUCCESSFUL)
                            {
                                //Retrieve the saved request id     
                                //long downloadID = preferenceManager.getLong(strPref_Download_ID, 0);
                                var uri = downloadManager.getUriForDownloadedFile(id);


                                Toast.makeText(this, new { id, uri }.ToString(), Toast.LENGTH_LONG).show();

                                // jsc ignores this type in import?
                                Button __ref0;

                                b.WithText("Download " + name1);
                                b.setEnabled(true);

                                //ParcelFileDescriptor file;
                                //try
                                //{
                                //    file = downloadManager.openDownloadedFile(downloadID);
                                //    //FileInputStream fileInputStream       = new ParcelFileDescriptor.AutoCloseInputStream(file); 
                                //    //Bitmap bm = BitmapFactory.decodeStream(fileInputStream);
                                //    //image.setImageBitmap(bm);   
                                //}
                                //catch // (FileNotFoundException e) 
                                //{      // TODO Auto-generated catch block   
                                //    //e.printStackTrace();     
                                //    throw;
                                //}
                            }
                        }
                    };

                }
            );


            this.setContentView(sv);
        }
        protected override void onCreate(Bundle savedInstanceState)
        {
            // https://forums.oculus.com/viewtopic.php?f=67&t=22766

            var activity = this;
            // http://stackoverflow.com/questions/11425020/actionbar-in-a-dialogfragment
            //To show activity as dialog and dim the background, you need to declare android:theme="@style/PopupTheme" on for the chosen activity on the manifest
            //activity.requestWindowFeature(Window.FEATURE_ACTION_BAR);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_DIM_BEHIND, WindowManager_LayoutParams.FLAG_DIM_BEHIND);
            //activity.getWindow().setFlags(WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager_LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //var @params = activity.getWindow().getAttributes();
            ////@params.height = WindowManager_LayoutParams.FILL_PARENT;
            ////@params.width = 850; //fixed width
            ////@params.height = 450; //fixed width
            //@params.alpha = 1.0f;
            //@params.dimAmount = 0.5f;
            //activity.getWindow().setAttributes(@params);
            //activity.getWindow().setLayout(850, 850);
            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);

            var b = new Button(this).AttachTo(ll);



            b.WithText("before AtClick");
            b.AtClick(
                v =>
                {
                    b.setText("AtClick");
                }
            );


            AtPrepareOptions +=
                value =>
                {
                    value.clear();

                    var item1 = value.add(
                         (java.lang.CharSequence)(object)"http://abstractatech.com"
                    );



                    item1.setIcon(android.R.drawable.ic_menu_view);

                    var item2 = value.add(
                        (java.lang.CharSequence)(object)"http://jsc-solutions.net"
                    );

                    //item2.setIcon(android.R.drawable.ic_menu_edit);
                    item2.setIcon(android.R.drawable.ic_menu_view);

                    var i = new Intent(Intent.ACTION_VIEW,
                        android.net.Uri.parse("http://jsc-solutions.net")
                    );

                    // http://vaibhavsarode.wordpress.com/2012/05/14/creating-our-own-activity-launcher-chooser-dialog-android-launcher-selection-dialog/
                    var ic = Intent.createChooser(i, "http://jsc-solutions.net");


                    item2.setIntent(
                        ic
                    );
                };

            AtOption +=
                item =>
                {

                    //b.WithText("menu was clicked!" + (string)(object)item.getTitle());
                    b.WithText("menu was clicked!" + new { item });
                };

            var b2 = new Button(this);

            var sw = System.Diagnostics.Stopwatch.StartNew();

            // SystemService
            Action update = delegate
            {
                // newer SDKS hide it

                // X:\opensource\ovr_mobile_sdk_0.5.1\VRLib\jni\VrApi\VrApi.cpp
                int cpuCore = 0;


                var online =
                    System.IO.File.ReadAllText("/sys/devices/system/cpu/cpu4/online").Trim();

                if (online == "1")
                    cpuCore = 4;

                var cpuFreq =
                    System.IO.File.ReadAllText("/sys/devices/system/cpu/cpu" + cpuCore + "/cpufreq/scaling_cur_freq").Trim();

                var cpuFrezMhz =
                    long.Parse(cpuFreq) / 1000;

                // 0 if gpu is not used?
                var gpuFreq =
                  System.IO.File.ReadAllText("/sys/devices/14ac0000.mali/clock").Trim();


                // const int64_t cpuFreq = ReadFreq( "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_cur_freq", cpuCore );

                b2.setText(
                    new { cpuCore, online, cpuFrezMhz, gpuFreq }.ToString()
                    + "\n " + sw.ElapsedMilliseconds
                    );
            };

            var h = new Handler();

            var next = default(Action);

            next = delegate
            {
                // await 1?

                update();

                h.postDelayed(
                    new xRunnable
                    {
                        yield = delegate
                        {
                            next();
                        }
                    },
                1);
            };

            next();


            ll.addView(b2);

            this.setContentView(sv);



            vConfigurationChanged = e =>
            {
                var orientation = getScreenOrientation();

                var SystemUiVisibility = getWindow().getDecorView().getSystemUiVisibility();

                //b2.setText(
                //    new
                //    {
                //        orientation,
                //        SystemUiVisibility
                //    }.ToString()
                //);


                if (orientation == Configuration.ORIENTATION_LANDSCAPE)
                {
                    hideSystemUI();
                }
                else
                {
                    showSystemUI();
                }
            };

            vConfigurationChanged(null);
        }
Exemplo n.º 33
-1
        protected override void onCreate(Bundle arg0)
        {
            base.onCreate(arg0);

            LinearLayout layout = new LinearLayout(this);
            layout.setOrientation(LinearLayout.VERTICAL);

            TextView tv = new TextView(this);
            tv.setText("Hello");
            tv.setTextSize(20);
            layout.addView(tv);

            tv = new TextView(this);
            tv.setText("World!");
            tv.setTextSize(15);
            tv.setTextColor(unchecked((int)0xFF00FFFF));
            layout.addView(tv);

            button = new Button(this);
            button.setText("wtf");
            layout.addView(button);
            button.setOnClickListener(new OnClickListener()
            {
                OnClick = (v) =>
                {
                    Console.WriteLine(toString());
                    button.setText(System.Environment.TickCount.ToString());
                }
            });
            /* 
             * Normally in Java, you'd handle the onClickListener with an inner class.
             * In C# there is no inner class construct.
            button.setOnClickListener(new OnClickListener()
            {
                @Override
                public void onClick()
                {
                }
            });
            */

            setContentView(layout);
        }