Beispiel #1
0
        protected override void OnCreate(Android.OS.Bundle bundle)
        {
#if MONODROID_TIMING
            Log.Info("MonoDroid-Timing", "HelloActivity.OnCreate: time: {0}", (DateTime.Now - new DateTime(1970, 1, 1)).TotalMilliseconds);
#endif
            base.OnCreate(bundle);
            Console.WriteLine("this is my\nstdout\nmessage! yay!");
            Console.Error.WriteLine("this is my\nstderr\nmessage! yay!");

#if __ANDROID_11__
            // Android 11+ _really_ doesn't want you to do networking from the main thread:
            //   http://developer.android.com/reference/android/os/NetworkOnMainThreadException.html
            // I want to do so, so...
            var policy = new Android.OS.StrictMode.ThreadPolicy.Builder()
                         .PermitAll()
                         .Build();
            Android.OS.StrictMode.SetThreadPolicy(policy);
#endif

            if (typeof(OnCreateApp) != ApplicationContext.GetType())
            {
                throw new InvalidOperationException("Wrong Application type created!");
            }
            if (typeof(OnCreateApp) != Application.Context.GetType())
            {
                throw new InvalidOperationException("Wrong Application.Context type created!");
            }
            if (!object.ReferenceEquals(Application.Context, ApplicationContext))
            {
                throw new InvalidOperationException("Wrong Application.Context instance created!");
            }

            var ignore  = new HelloActivity();
            var ignore2 = new CompanyAdapter(this, 0, new string [0]);

            RequestWindowFeature(WindowFeatures.NoTitle);

            StartService(new Intent(this, typeof(MyService)));

            textview      = new TextView(this);
            textview.Text = "Hello MonoDroid.  Mono loves you.\n\nEmbedded\u0000Nulls";
            #region BNC_635129
            textview.Tag = "2";
            if (Convert.ToString(textview.Tag) != "2")
            {
                throw new InvalidOperationException("Tag(\"2\") != \"2\"!");
            }
            #endregion
            TestDllImport(textview);

            #region BNC_679599
            bar = new B <A> ();
            bar.Do();
            #endregion

            var tempfile = Path.GetTempFileName();
            textview.Text += "\n\nPath.GetTempFileName()=" + tempfile;
            File.Delete(tempfile);

            int[] style = global::Mono.Samples.SanityTests.Resource.Styleable.NavBar;

            textview.Text += "\n\nEncoding.GetEncoding(1252).EncodingName=" +
                             Encoding.GetEncoding(1252).EncodingName;

            TestGzip();
            TestArrays();
            TestTypeConversion();
            TestJniInvocation(textview);
            TestManualOverrides();
            TestBnc631336();
            TestBnc632470();
            TestBnc654527(textview);
            var db = ItemsDb.Instance;
            TestSqlite(textview);
            TestProxyInstantiation();
            TestHttps(textview);
            TestExceptions(textview);
            TestJavaManagedJavaManagedInvocation();
            TestInputStream(textview);
            TestOutputStream(textview);
            TestStreamInvokers(textview);
            TestNonJavaObjectGenerics(textview);
            TestUrlConnectionStream(textview);
            TestConvert(textview);
            TestTimeZoneInfo(textview);
            TestAssets(textview);
            TestUdpSocket(textview);
            TestNonStaticNestedType(textview);
            TestFinalization(textview);
#if MAPS
            TestMaps(textview);
#endif
            TestNumerics(textview);
            TestManagedToJniLookup_Release(textview);

            var die = new TextView(this)
            {
                Text = "Added!",
            };
            WindowManager.AddView(die, new WindowManagerLayoutParams());
            WindowManager.RemoveView(die);

            var scrollView = new ScrollView(this);
            scrollView.AddView(textview);
            SetContentView(scrollView);
            textview.Touch += OnTouch;

            ThreadPool.QueueUserWorkItem(o => {
                Log.Info("*jonp*", "Hello from the thread pool thread!");
                RunOnUiThread(() => textview.Text += "\n\nThreadPool update!");
            });
            GC.Collect();
        }