addCategory() public method

public addCategory ( java arg0 ) : global::android.content.Intent
arg0 java
return global::android.content.Intent
        // https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20150926
        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201511/20151121

        //        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


        // "x:\util\android-sdk-windows\platform-tools\adb.exe" shell am start -n "AndroidListApplications.Activities/.ApplicationWebServiceActivity"


        /// <summary>
        /// This Method is a javascript callable method.
        /// </summary>
        /// <param name="e">A parameter from javascript.</param>
        /// <param name="yield">A callback to javascript.</param>
        public Task queryIntentActivities(yield_ACTION_MAIN yield)
        {
            var context = ThreadLocalContextReference.CurrentContext;


            // http://stackoverflow.com/questions/2695746/how-to-get-a-list-of-installed-android-applications-and-pick-one-to-run
            // https://play.google.com/store/apps/details?id=com.flopcode.android.inspector

            var mainIntent = new Intent(Intent.ACTION_MAIN, null);

            mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);


            var pm = context.getPackageManager();

            var pkgAppsList = pm.queryIntentActivitiesEnumerable(mainIntent)
                .OrderBy((android.content.pm.ResolveInfo k) => k.activityInfo.packageName)
                .WithEach(
                r =>
                {
                    // http://stackoverflow.com/questions/6344694/get-foreground-application-icon-convert-to-base64

                    var label = (string)(object)pm.getApplicationLabel(r.activityInfo.applicationInfo);

                    var icon_base64 = "";

                    try
                    {
                        var icon = pm.getApplicationIcon(r.activityInfo.applicationInfo);

                        if (icon != null)
                        {

                            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                            // bitmap.compress(CompressFormat.PNG, 0, outputStream); 

                            BitmapDrawable bitDw = ((BitmapDrawable)icon);
                            Bitmap bitmap = bitDw.getBitmap();
                            ByteArrayOutputStream stream = new ByteArrayOutputStream();
                            bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
                            var bitmapByte = (byte[])(object)stream.toByteArray();

                            // this will take forever
                            //icon_base64 = Convert.ToBase64String(bitmapByte);

                            //bitmapByte = Base64.encode(bitmapByte,Base64.DEFAULT);
                            //System.out.println("..length of image..."+bitmapByte.length);
                        }
                    }
                    catch
                    {

                    }


                    yield(
                        r.activityInfo.applicationInfo.packageName,
                        r.activityInfo.name,

                        icon_base64: icon_base64,
                        label: label
                    );
                }
            );

            //yield_done();

            return new object().ToTaskResult();
        }
        public void Launch(
            string packageName,
            string name,

            string ExtraKey = "ExtraKey",
            string ExtraValue = "ExtraValue"
            )
        {
            // http://stackoverflow.com/questions/12504954/how-to-start-an-intent-from-a-resolveinfo
            var c = new ComponentName(packageName, name);
            Intent i = new Intent(Intent.ACTION_MAIN);

            i.addCategory(Intent.CATEGORY_LAUNCHER);
            i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                        Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
            i.setComponent(c);

            // http://stackoverflow.com/questions/11860074/start-activity-for-result
            // http://stackoverflow.com/questions/2844440/passing-arguments-from-loading-activity-to-main-activity
            i.putExtra(ExtraKey, ExtraValue);


            var context = ThreadLocalContextReference.CurrentContext;

            context.startActivity(i);
        }