Tips and Tricks in a world of Mix

Posts tagged ‘visual studio’

Call java object from javascript

More and more I see entire products built on this ability which is pretty simple really .

How can we connect a responsive and dynamic UI such as Html5 that is able to migrate easily between devices with the Java ability of controlling the device under Android OS ? 

The idea is to :

  1. Set the promise and enabling usage of javascript interface in Java
  2. Create the corresponding implementation for the javascript interface in Java 
  3. Call the Java class and functionality from javascript – letting you control the device with the whole power of Java drivers from html5 – JQuery UI .

How to recipe :

  • in App.java :   

private DefMemoryReleaser  dmr ;

   super.appView.getSettings().setJavaScriptEnabled(true);

   dmr = new DefMemoryReleaser(this, appView);

   appView.addJavascriptInterface(dmr, “JavaDefMemoryReleaser”);

 

  •  buildjava corresponding class DefMemoryReleaser

package com.EggedDefinition;

import org.apache.cordova.DroidGap;

import android.webkit.WebView;

public class DefMemoryReleaser {

         private WebView mAppView;

         private DroidGap mGap;

          public DefMemoryReleaser(DroidGap gap, WebView view)

         {

           mAppView = view;

           mGap = gap;

         }

         public void freeMemory(){

                System.runFinalization();

               Runtime.getRuntime().gc();

               System.gc();

         }

       }

 

  • in javascript : 

if (typeof (window.JavaDefMemoryReleaser) != ‘undefined’)

       window.JavaDefMemoryReleaser.freeMemory();

 

Now you are ready and set to build and sell security products for Android – Godspeed !  🙂

Advertisements

VS 2010 crash opening Ria Services Library

 

Problem signature:
  Problem Event Name:    CLR20r3
  Problem Signature 01:    devenv.exe
  Problem Signature 02:    10.0.40219.1
  Problem Signature 03:    4d5f2a73
  Problem Signature 04:    Microsoft.VisualStudio.Platform.VSEditor
  Problem Signature 05:    10.0.0.0
  Problem Signature 06:    4d5f07e4
  Problem Signature 07:    1874
  Problem Signature 08:    2e
  Problem Signature 09:    System.NullReferenceException
  OS Version:    6.1.7600.2.0.0.256.48
  Locale ID:    1033

 

Tools > Options > Productivity Power Tools : Enhanced Scrollbar

By disabling the Enhanced Scrollbar tool the error disappears for me.

Microsoft Visual Studio 2010 Service Pack 1 (Installer) is out!

Microsoft Download

As they say :

This service pack release addresses issues that were found through a combination of customer and partner feedback, as well as internal testing. These service packs offer Visual Studio users improvements in responsiveness and stability, as well as completes some high-impact scenarios requested by customers.

What means :

Less time waiting for the compilation to end .. 🙂

A full description here .

 

Will try it out in a few days and report the outcome .

VS2010 Improvements – My Summary

Watch it on line or download

VS2010 fully implemented with WPF.

 

Code editing improvements

Intellisence improvements :

– Searching for a method or class —

   you can access  “this.”    and then you can insert only some part of your function name or if you are using a Camel case / Pascal  convention of names you can type only the capital letters  and it’ll find the function for you .

– Navigate to dialog – Ctrl + “,”

    type some word you are looking for and get all the references of the word in all the project and jump to the desired location.

   also can use Pascal capital letters for the search through Navigate to dialog.

– View call hierarchy – Stand over your function and in right click you have this new option.

    you’ll get all the objects that use this and all the objects this is using .

– Generate Diagram Sequence  – Stand over your function and in right click you have this new option.

    it’ll build a full diagram sequence for you. You can define the depth of the diagram. This function exists only in the VS2010 Ultimate version  – very cool feature.

    through the diagram you can change the sequence , go to the actual code , customize the layout

 

– With Alt + choose with mouse some text – you can choose some code vertically and do with it something – like tab it or remove it.

Code Snippets – added also to Html and Javascript Editors

 

Javascript  –

         type “control” in js file and press TAB twice –

you’ll get snippet , that when you’ll change the namespace it’ll update itself:

 

Type.registerNamespace("myControl,UI"); 
 
myControl,UI.mycontrol = function (element) {
    myControl,UI.mycontrol.initializeBase(this, [element]);
} 
 
myControl,UI.mycontrol.prototype = {
    initialize: function () {
        myControl,UI.mycontrol.callBaseMethod(this, 'initialize');
    },
    dispose: function () {
        myControl,UI.mycontrol.callBaseMethod(this, 'dispose');
    }
} 
 
myControl,UI.mycontrol.registerClass('myControl,UI.mycontrol', Sys.UI.Control);
 
 
 
Html -
     just type textbox and press TAB twice - 
     it’ll build the control for you - 
<asp:TextBox runat="server" />  

so , now if you’ll add an id for it :

<asp:TextBox runat="server" id= "MyTextBox" /> 
and type bellow a word require it’ll add :
 <asp:RequiredFieldValidator ErrorMessage="errormessage" ControlToValidate="MyTextBox" runat="server" />

few more snippets

– just write “script” + TABx2 when you want to pen Javascript block.

– just write “a”  + TABx2  when you want to create some hyperlink , and you can update its properties just by clicking the tab each time ,                 without using the mouse.

 

 

Debbuging options –

Can go back and forth inside the debugging process . (This function exists only in the VS2010 Ultimate version or in testing targeted versions. Not in Premium ).

Black box feature  -Can export the debugging process to another machine , import it there and recreate the test.  – take a call dump of information of an application that crushed , either a Client App or a Server app on a different machine – they will give  as all the traces – call stack .. . 

Interactive testing allowing people without VS to perform tests on applications.

Call Stack Information more readable for the human eye.

 

 

Not from the lecture –

Useful Extension for VS that I love to use are:

Power Commands  – this one is the best

Productivity Power  Tools .

You can download it through the VS2010 Tools-> Extension Manager editor

Tag Cloud

%d bloggers like this: