Wednesday, March 02, 2016

Static

Static keyword

1) static variables
2) static methods
3) static blocks of code.

static variable

  • It is a variable which belongs to the class and not to object(instance)
  • Static variables are initialized only once , at the start of the execution . These variables will be initialized first, before the initialization of any instance variables
  • A single copy to be shared by all instances of the class
  • A static variable can be accessed directly by the class name and doesn’t need any object
  • Syntax : <class-name>.<variable-name>
class Book {
    public static String Title;
    public static String Author;
    int yearPublished;
}

public class StaticMain2 {
    public static void main(String[] args) { //no need an instance of class
                                             //otherwise Book b = new Book();
                                             // to access b.yearPublished
        Book.Title = "Psychology and Human Evolution";
        Book.Author = "Jeannot Lamm";
           
    }
}

         static method

  • It is a method which belongs to the class and not to the object(instance)
  • A static method can access only static data. It can not access non-static data (instance variables)
  • A static method can  call only  other static methods and can not call a non-static method from it.
  • A static method  can be accessed directly by the class name and doesn’t need any object
  • Syntax : <class-name>.<method-name>
  • A static method cannot refer to "this" or "super"  keywords in anyway

          static block

           The static block, is a block of statement inside a Java class that will be executed when a class is first loaded in to the JVM

          class Test{
           static {
           //Code goes here
          }
           }
 
public static void main(String[] args){
  Thread t1 = new Thread(new Runnable() {
...
private static void producer(){  //static function in a class since no object (new) defined static
  Random random = new Random();
  while(true){
   try {
//    Integer val = random.nextInt(100);
    queue.put(random.nextInt(100)); //range 0 - 99
   } catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  }
 }
Static initialize block is executed even before JVM calls main method. They are executed when a Class is loaded into Memory by JVM.

In C/C++:
- A static variable, declared globally, will only be visible in that source file. Static functions are functions that are only visible to other functions in the same file. Global all files can access it using C keyword extern.

 static int varl //can't be seen from outside files, limit the scope.
 int var;          //Variables that are defined outside functions - global variables. Can see from outside
- The variable is permanent. The variable can only be initialized once and only one copy of the variable exists.(initialized at compilation time), retains it value between calls.
-Only one copy if the variable exits. All instances of the object use the same variables
-Static Function can only access static members/fields of the class but non-static member function can access static member function or data(see example below) and it can call only other static member functions. Normally, the address of the current object(this) is passed in when any member function is called, but a static member has no "this" which is the reason it cannot access ordinary members a bit faster since doesn't have (this). At the same time you get the benefits of having the function inside the class (p.473 of Thinking of C++ Bruce Eckel.). Static members have the same properties as global variables but enjoying class scope. It is a global variables, the only difference is its name outside the class. Static data members of a class are also known as "class variables" is a variable defined in a class of which a single copy exists, regardless of how many instances of the class exist. It does not depend on any object. There is only one unique value for all the objects of that same class. For the above reasons main in Java has a static keyword.
          public static void main(String args[])
The keyword static allows main() to be called without having to instantiate a particular instance of the class. This is necessary since main() is called by the Java interpreter before any objects are made. Before the main method is called, no objects are instantiated. Having the static keyword means the method can be called without creating any objects first. The main() method in C++, C# and Java are static because they can then be invoked by the runtime engine without having to instantiate an instance of the parent class. Now main without keyword static.
          public void main(String args[])
Exception in thread "main" java.lang.NoSuchMethodError: main (cannot find main because no object is initiated for main)
Since main method is static Java virtual Machine can call it without creating any instance of class which contains main method. Otherwise JVM has to create instance of main Class and since constructor main() can be overloaded and can have arguments there would not be any certain and consistent way for JVM to find main method in Java. All objects of non-primitive types can be created only via "new" in Java. There is no equivalent to creating non-primitive objects on the stack as in C++. Anything which is declared in class in Java comes under reference type and requires object to be created before using them but static method and static data are loaded into separate memory inside JVM called context which is created when a class is loaded. If main method is static than it will be loaded in JVM context and are available to execution.
-Static will remain reserved for the duration of the execution program. Consider this bit of code.
 char *func(void);

        main()
        {
            char *Text1;
            Text1 = func();
        }

        char *func(void)
        {
            char Text2[10]="martin";
            return(Text2);
        }

 Now, 'func' returns a pointer to the memory location where 'text2' starts BUT text2 has a storage class of 'auto' and will disappear when we exit the function and could be overwritten but something else. The answer is to specify
        static char Text[10]="martin";


class Student {
        int a; //initialized to zero
        static int b; //initialized to zero only when class is loaded not for each object created.

          Student(){
           //Constructor incrementing static variable b
           b++;
          }


           public void showData(){
              System.out.println("Value of a = "+a);
              System.out.println("Value of b = "+b);
           }
        //public static void increment(){
        //a++;
        //}

        }

        class Demo{
           public static void main(String args[]){
             Student s1 = new Student();
             s1.showData();
             Student s2 = new Student();
             s2.showData();
        //     Student.a++;  //cannot access instance variable "a" from static method "increment"
        //     s1.showData();
          }
        }
//: C10:StaticMemberFunctions.cpp
class X {
int i;
static int j;
public:
 X(int ii = 0) : i(ii) {
 // Non-static member function can access
 // static member function or data:
 j = i;
 }
 int val() const { return i; }
 static int incr() {
 //! i++; // Error: static member function
 // cannot access non-static member data
 return ++j;
 }
 static int f() {
 //! val(); // Error: static member function
 // cannot access non-static member function
 return incr(); // OK -- calls static
 int v;
 }
};
int X::j = 0;  // a static for all objects it works
//int X::i = 1;  // error: ‘int X::i’ is not a static member of ‘class X’

int main() {
 X x;
 X* xp = &x;
 x.f();
 xp->f();
 X::f(); // with static Only works with static members. error: cannot call member function ‘int X::f()’ without object
 x.f();  // without static need an object
// int X::j = 0;
} ///:~

C++ Static Class: C++ doesn't directly support a static class only Static data members and Static member functions. There is no "static class" in C++. The nearest concept would be a class with only static methods


See http://stackoverflow.com/questions/1303947/c-compiler-warning-returning-local-variable/35777878#35777878
class Three
{
    string *m_ob;
    int m_x, m_y, m_z;
public:
    Three(){}
    Three(string ob, int x, int y, int z): m_ob(new string(ob)), m_x(x), m_y(y), m_z(z) {}
    Three &operator+(Three &t)
    {
        static Three th;  //static here otherwise return this object is gone!
        th.m_ob = new string("Sum object");
        cout << "---------" << this->m_x << " " << t.m_x << endl;
        th.m_x = this->m_x + t.m_x;
        th.m_y = this->m_y + t.m_y;
        th.m_z = this->m_z + t.m_z;
        return th; //create in stack gone when return
    }

    friend ostream &operator<< (ostream &stream, Three t)
    {
        stream << *t.m_ob <<": ",
        stream << t.m_x << ",";
        stream << t.m_y << ",";
        stream << t.m_z << "\n";
        return stream;
    }
};

int main()
{
    Three ob1("ob1", 1, 2, 3), ob2("ob2", 4, 5, 6), ob3("ob3", 7, 8, 9);
    cout << ob1 << ob2 << ob3 << endl;
    Three ob = ob1 + ob2 + ob3;
    cout << ob << endl;
}
//Without static Three th will error: warning: reference to local variable ‘th’ returned [-Wreturn-local-addr]
//object create in stack it is gone when return. In c_cpp_reference when return value need static.

Inline functions versus Macros

 Although inline functions are similar to macros (because the function code is expanded at the point of the call at compile time), inline functions are parsed by the compiler, whereas macros are expanded by the preprocessor. As a result, there are several important differences:
  1.  Inline functions follow all the protocols of type safety enforced on normal functions.
  2.  Inline functions are specified using the same syntax as any other function except that they include the inline keyword in the function declaration.
  3.  Expressions passed as arguments to inline functions are evaluated once. In some cases, expressions passed as arguments to macros can be evaluated more than once.

    // inline_functions_macro.c
    
        #include <stdio.h>
        #include <conio.h>
    
        #define toupper(a) ((a) >= 'a' && ((a) <= 'z') ? ((a)-('a'-'A')):(a))
    
        int main() {
           char ch;
           printf_s("Enter a character: ");
           ch = toupper( getc(stdin) );
           printf_s( "%c", ch );
        }
    
        Input
    
        xyz
    
        Inline functions remedy the problem previously described.
    
        // inline_functions_inline.cpp
        #include <stdio.h>
        #include <conio.h>
    
        inline char toupper( char a ) {
           return ((a >= 'a' && a <= 'z') ? a-('a'-'A') : a );
        }
    
        int main() {
           printf_s("Enter a character: ");
           char ch = toupper( getc(stdin) );
           printf_s( "%c", ch );
        }
    
        Input
    
        a
    
        Output
    
        Enter a character: A

String, StringBuffer and StringBuilder in Java


Differences between String and StringBuffer in Java
Main difference between String and StringBuffer is String is immutable while StringBuffer is mutable means you can modify a StringBuffer object once you created it without creating any new object. This mutable property makes StringBuffer an ideal choice for dealing with Strings in Java. You can convert a StringBuffer into String by its toString() method. String vs StringBuffer or what is difference between StringBuffer and String is one of the popular interview questions for either phone interview or first round. Now days they also include StringBuilder and ask String vs StringBuffer vs StringBuilder. So be preparing for that. In the next section we will see difference between StringBuffer and StringBuilder in Java.
Difference between StringBuilder and StringBuffer in Java
StringBuffer is very good with mutable String but it has one disadvantage all its public methods are synchronized which makes it thread-safe but same time slow. In JDK 5 they provided similar class called StringBuilder in Java which is a copy of StringBuffer but without synchronization. Try to use StringBuilder whenever possible it performs better in most of cases than StringBuffer class. You can also use "+" for concatenating two string because "+" operation is internal implemented using either StringBuffer or StringBuilder in Java. If you see StringBuilder vs StringBuffer you will find that they are exactly similar and all API methods applicable to StringBuffer are also applicable to StringBuilder in Java. On the other hand String vs StringBuffer is completely different and there API is also completely different, same is true for StringBuilders vs String.


Java provides the StringBuffer and String classes, and the String class is used to manipulate character strings that cannot be changed. Simply stated, objects of type String are read only and immutable. The StringBuffer class is used to represent characters that can be modified.

The significant performance difference between these two classes is that StringBuffer is faster than String when performing simple concatenations. In String manipulation code, character strings are routinely concatenated. Using the String class, concatenations are typically performed as follows:
String str = new String ("Stanford ");
str += "Lost!!";
If you were to use StringBuffer to perform the same concatenation, you would need code that looks like this:
StringBuffer str = new StringBuffer ("Stanford ");
str.append("Lost!!"
More...
String s = "a" + "b" + "c";
It is rather pointless to use StringBuffer.
String s = new StringBuffer().append("a").append("b").append("c").toString();
String s = "";
for (int i = 0; i < 10; i++) {
s = s + Integer.toString(i);
}


Using string in this loop will generate 10 intermediate string objects in memory: "0", "01", "012" and so on. While writing the same using StringBuffer you simply update some internal buffer of StringBuffer and you do not create those intermediate string objects that you do not need:


StringBuffer sb = new StringBuffer();
for (int i = 0; i < 10; i++) {
sb.append(i);
}
Actually for the example above you should use StringBuilder (introduced in Java 1.5) instead of StringBuffer - StringBuffer is little heavier as all its methods are synchronized.

Summary:

In Java, String concatenation operator (+) is internally implemented using StringBuffer.
String str = "Hello" + "World";
Would be executed as,
Concatenation operator "+" is internal implemented using either StringBuffer or StringBuilder.
String str = new StringBuffer().append("Hello").append("World").toString();
First an empty StringBuffer will be created and then operands of the + operator would be appended using append method of the StringBuffer.
Finally toString() method of the StringBuffer would be called to convert it to string object and the same will be returned.
String concatenation using this approach is very expensive in nature, because it involves creation of temporary StringBuffer object. Then that temporary object’s append method gets called and the resulting StringBuffer should be converted to back String representation using toString() method.
When to use String and when StringBuffer?
If there is a need to change the contents frequently, StringBuffer should be used instead of String because StringBuffer concatenation is significantly faster than String concatenation
String is immutable while StringBuffer and StringBuilder is mutable object
When to use StringBuffer and when StringBuilder
StringBuffer is synchronized while StringBuilder is not which makes StringBuilder faster than StringBuffer.
Use String if you require immutability, use Stringbuffer in java if you need mutable + threadsafety and use StringBuilder in Java if you require mutable + without thread-safety
Ref:
http://javarevisited.blogspot.ca/2011/07/string-vs-stringbuffer-vs-stringbuilder.html http://www.javaworld.com/javaworld/jw-03-2000/jw-0324-javaperf.html

Const vs. Final

In Java const is just a reserve keyword, there is no const in Java. But it can be done similar to const in C++. You can create a constant variable in a class. To create a constant variable, type the final keyword to the left of the variable. Once again, when declaring a constant, you must initialize it with an appropriate constant value. static final in MAX_UNITS = 25; in C++ const MAX_UNITS = 25; A final variable in Java can be assigned to only once, but if the variable is a reference-type, you can still change what it refers to. A const variable in C++ can be assigned to only once, where it’s declared, and nothing is allowed to change about the value, whether it’s an object or not.

this Instance

If a class contains member variables and methods, the (non-static) member variables are automatically available to the method(s) of the class, even member variables that are private. When accessing a member variable or a method from another method of the class, to indicate that the member you are accessing belongs to the same class, you can precede it with the this member and the period operator.

C++ vs. Java

  1. C less rules than C++, C++ is less rules than Java. Java many things you don't have to worry but many rules have to follow.
  2. By default, all members of a class are private and all the members of structure are public in C++ and by default, all the members of a Java class are public. This means that if you do not use the public or the private keyword, a field is automatically made by default scope. (access specifiers to use specify the scope of members of the class and the class itself). If the class has no specifier by default then such a class will be accessible from inside the same package. The class can either public or no specifier.
    public or no modifier - the same way as used in the class level
    private - members can only access
    protected -can be accessed from the same package and a subclass existing in any package can access.
  3. Java has char type uses the international 16-bit Unicode, C++ has char type 1 byte for 32-bit system and 2 bytes for 64-bit system.
  4. C-language did not contain any data types to represent a Boolean value. Both the C++ and Java languages have Boolean types.
    C++
    bool foo;
    Java
    boolean foo;
     
    
    
  5. Pointers
    The Java language does not include pointers. The reason for this is simple: pointers tend to cause confusion in the code, and they are a common source of bugs. Java references are pointers to Java objects, but you can't use Java references in the same way that you can use C pointers. Java references cannot be incremented or decremented, you can't convert references to or from primitive types, and there are no address of operators, such as &, or dereferencing operators, such as -> or *.
  6. Global variables: Unlike C and C++, the Java language offers no way to declare global variables (or methods).
  7. The preprocessor: The Java platform does not have a preprocessor, nor does it have any preprocessor directives or macros.
  8. goto: Although the Java language reserves goto as a keyword, there is no goto statement like the one used in C.
  9. struct, union, typedef, enum: The Java language does not have the struct or union types, nor does it have the typedef or enum keywords.
  10.  Freely placed variables: Java variables can be declared anywhere, as they are needed. Variables do not need to be grouped together at the top of a block, as they do in C.
  11. Freely placed methods: C requires that function declarations appear before they are invoked, but Java methods can be invoked before they have been declared.
  12. Garbage collection: The Java platform uses a garbage collector to
    automatically reclaim memory by recycling objects when they are no
    longer referenced. The malloc() and free() functions used by C
    aren't necessary in Java programming, and no similar methods exist for
    the Java language.
  13. No difference between Access Modifiers and Access Specifiers. Different names for the same.
    Access modifiers: abstract, final and strictfp . Access specifier: public,private, protected or default. 
    Java access Specifier are used to specify how the member variable ,methods or class to other classes.
    They are public ,private and protected.
    
    Access Modifier:
       1.Access
       2.Non Access
    
    Access:
        public ,private,protected and default.
    Non Access:
     abstract,final,native,static,synchronized,transient,volatile
     and strictfp
     
  14. What's the difference between an interface and an abstract class?
    • An abstract class is a class that is only partially implemented by the programmer. It may contain one or more abstract methods. An abstract method is simply a function definition that serves to tell the programmer that the method must be implemented in a child class.
    • An interface is similar to an abstract class; indeed interfaces occupy the same namespace as classes and abstract classes. For that reason, you cannot define an interface with the same name as a class. An interface is a fully abstract class; none of its methods are implemented and instead of a class sub-classing from it, it is said to implement that interface.
    • Abstract classes can have constants, members, method stubs and defined methods, whereas interfaces can only have constants and methods stubs.
    • Methods and members of an abstract class can be defined with any visibility, whereas all methods of an interface must be defined as public.
    • When inheriting an abstract class, the child class must define the abstract methods, whereas an interface can extend another interface and methods don't have to be defined.
    • A child class can only extend a single abstract (or any other) class, whereas an interface can extend or a class can implement multiple other interfaces.
    • A child class can define abstract methods with the same or less restrictive visibility, whereas a class implementing an interface must define the methods with the exact same visibility 
  15. When to use abstract class or interface?
    • Interface is used when you only want to declare which methods and members a class MUST have. Anyone implementing the interfaca will have to declare and implement the methods listed by the interface.
    • If you also want to have a default implementation, use abstract class. Any class extending the abstract class will have to implement only its abstract methods and members, and will have some default implementation of the other methods of the abstract class, which you may override or not.
    • Finally, you can implement as many interfaces as you want, but only extend one class (being it abstract or not). Keep that on mind before choosing.
    • public class C implements A, B{... }
    • public class C extends A{...}
    • Abstract class is an incomplete implementation of some concept. This incomplete implementation may be different in different context. Derived class implements the abstract class in its context.
    • Interface defines contract or standard. Implementation of the interface has to follow the contract or standard. Interfaces are more used to set these types of standards or contract
  16.  What does the Serializable interface do ?
    • The Serializable interface is just a marker. It means that objects can be serialized, i.e. they can be represented as a bit string and restored from that bit string. For example, both of your classes are serializable because they can be represented as a bit string (or regular string). On the other hand, a class that represents a file handle given out by the operating system can not be serialized: As soon as the program is finished, that handle is gone, and there is no way to get it back. Reopening the file by file name is not guaranteed to work, since it may have been deleted/moved/changed permissions in the meantime.
    • Serializing objects that don't implement the Serializable interface will result in a NotSerializableException being thrown
  17. How you can force the garbage collection ?
    • Garbage collection automatic process and can't be forced. You could request it by calling System.gc(). JVM does not guarantee that GC will be started immediately.
    • Garbage collection is one of the most important feature of Java, Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory. User program can't directly free the object from memory, instead it is the job of the garbage collector to automatically free the objects that are no longer referenced by a program.
    •  Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. I Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.
  18. What is Synchronization in Java?
    • Synchronization is a process of controlling the access of shared resources by the multiple threads in such a manner that only one thread can access one resource at a time.
    •  In non synchronized multithreaded application, it is possible for one thread to modify a shared object while another thread is in the process of using or updating the object's value.
  19. What is memory leak?
    • A memory leak is where an unreferenced object that will never be used again still hangs around in memory and doesnt get garbage collected.
  20.  What is the difference between checked and unchecked exceptions?
    • In general, unchecked exceptions represent defects in the program (bugs), which are normally Runtime exceptions.
    •  Furthermore, checked exceptions represent invalid conditions in areas outside the immediate control of the program.
  21.  How does Java allocate stack and heap memory?
    •  Each time an object is created in Java it goes into the area of memory known as heap. The primitive variables like int and double are allocated in the stack, if they are local method variables and in the heap if they are member variables (i.e. fields of a class).
    • In Java methods local variables are pushed into stack when a method is invoked and stack pointer is decremented when a method call is completed.
    •  In a multi-threaded application each thread will have its own stack but will share the same heap. This is why care should be taken in your code to avoid any concurrent access issues in the heap space.
    •  The stack is threadsafe (each thread will have its own stack) but the heap is not threadsafe unless guarded with synchronisation through your code
  22. What is Java Reflection?
    • Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine.

    Tuesday, July 16, 2013

    Thursday, October 18, 2012

    Install Google Apps using ADB for LG P690B

    First it needs to be root, this is the case for LG P690B when enabled debug and connected to PC via USB.
     C:\Users\tv\Downloads\SuperOneClickv2.2\ADB>adb shell
    $
    $ means unroot (just like sudo on linux root)

    Do root follow this link for instruction it takes about few minutes
    http://forum.xda-developers.com/showthread.php?t=1443115

    After doing the prompt will change from '$' to "#' (root as linux world)
    C:\Users\tv\Downloads\SuperOneClickv2.2\ADB>adb shell
    # ls  
     # means rooted

    Install apps without login to google account, if you follow the above link for root then you already have
    ADB installed in your computer. In my case it locates in Downloads directory below.
    C:\Users\tv\Downloads\SuperOneClickv2.2\ADB>adb install c:\users\tv\Downloads\Ti
    tanium_Backup_root_5_6_0.apk
    2335 KB/s (5768864 bytes in 2.412s)
            pkg: /data/local/tmp/Titanium_Backup_root_5_6_0.apk
    Success
    Titanium_Backup_root is installed without using Google Market which required Gmail account.
    More info. http://androidcommunity.com/forums/f4/how-to-install-apps-using-adb-4482/ 

    Without connecting to Google account the Wifi signal is Grey or White indicates that it is not sync to Google account because it is installed Google Apps using ADB. The following picture indicates that Wifi is white color it was capture using aScreenShoot apps. Beside the color everything is working surf the web and so on....
    With this in mind we can have Android phone runs all the apps without Google knowing about the phone the minute that you login into the Google account you can not logout and the phone is tracked the only thing gets out the Google account by doing the manufacture reset. I try clear data of Google apps or Account sync and none of them seems working. Manufacture reset will wipe out all the data and possible unroot the phone again.
    This is becoming important when people gives the phone away. Google should make easy for people to change account or remove account.

    Thursday, September 27, 2012

    Upgrade tablets Herotab C8 and Novo 7 Advanced to Android 4.0.3

    Please make sure back up your data because it will wipe out your data. You can use back up or restore or external tools: I am using Titanium. After finished upgrade just need to restore, it will save a lot of time instead of trying to remember which apps to install again. It is your own risk to do the upgrade, I have no responsible whatsoever regarding this upgrade.

    Herotab C8: 

    ROM F/W http://www.slatedroid.com/topic/37733-rom-updated-0809-ice-fusion-v02/ Instruction: http://www.slatedroid.com/topic/38255-rom-updated-0809-jol-cm10-alpha2/
    1. Extract the zip file to the external SD, or copying files, root.tgz, zImage, recovery, utscript ...... to external SD.
    2. Press power + menu to boot midRecovery. JellyBean need a larger system partition, if you are upgrading from another Rom necessary. repartition the internal SD, for this go to step
    3, if you already have the correct partitions at step 4. 3. Go to Advanced, "Partition SD card", size of cache 256, size of data 1024, size of system 512. When partitioning the SD erase all data and cache, no need to step
    4. go to step 5. 4. For maximum compatibility and that installation is clean with no trace of other Rom, is necessary, "Wipe data \ factory reset" and "wipe cache".
    5. Now it's time to install the Rom, go to "Flash ROM", select "(Select this directory)".
    6. If the ROM does not include Google applications, you need your installation. Go to "Apply patch \ update" and select the zip file. This step also applies to patch, just zip files, provided for our tablet.
    7. If a new kernel can update it. Go to "Partitions and Storage" and "kernel update", select the file zImage.
    8. Optionally you can flash the boot logo, Go to "Partitions and Storage" and "Update Logo", select the file logo.bmp.

    Ainol Novo 7 Advanced

    ROM F/W: http://www.flashmyandroid.com/forum/showthread.php?379-ROM-Ainol-Novo-7-Advanced-Official-ICS-Firmware-v4-0-3v1-0
    or http://www.bergfiles.com/i/bf535ed4e1h32i0
    Please note this ROM is from manufacture, it is rooted(good thing) and its default language is Chinese after finished upgraded you need to change the languages & input to your language i.e. for my case I change to English but you can guess where is language & input menu from the above picture. It is number 6th from the bottom up.
    09/17/2012  07:15 PM    <DIR>          ..
    03/08/2012  04:11 PM       331,604,992 Novo7Advanced_0308.img
    Imstruction: http://gadgetfreakz.co.uk/downloads/gfz-novo7/Ainol_Novo_7_Firmware_Update_Guide.pdf

    You need LiveSuit to connect device to PC to upgrade. Details as follows:


    Ainol Novo 7 Advanced Official ICS Firmware v4.0.3v1.0
    Download Link: will update soon
    Original download: http://115.com/file/bedviw81
    Original post: http://bbs.imp3.net/thread-10621519-1-1.html

    Installation:
    LiveSuit V1.07 http://www.mediafire.com/?idmeiyvr8xbt6rd
    Ainol_usb_driver http://www.mediafire.com/?oo4fo44mbkpbz4i
    Open LiveSuit then follow instructions.

    - After upgraded you may experience with wifi problem, you may see
    Under WIFI it says " obtaining IP address from WIFI NAME" then "scanning" then "connecting" then "disconnected." this cycles over and over.
    http://androidforums.com/le-pan-tc-970/469573-obtaining-ip-address.html
    It is easy to fix there is no thing wrong with the upgrade for some reasons it does not work with WEP security mode in 4.0.3 it prefers WPA or WPA2 Personal. Probably WEP is the least secure enscript.
    In my case I just need to login into my router and change from WEP to WPA2, WPA Algorithm to TKIP, WPA Shared Key and pick up a password. For all the wifi devices need to disconnect and connect again for them to work with the new setup if you keep the same password then all you have to do is disconnected/connected. That's all.


    - After upgraded if you experience some strange problems like the tablet is reset itself, please go to setting and do Factory/data reset it will stable again need to back up your data first. I was so disappointed after the upgrade and it kept reset itself, to wipe out erase all the data of the tablet and it did the treat.

    - If you run into the problem with linux you need to remove network-manager and install wicd, it works for your linux wifi. See http://ubuntuforums.org/showthread.php?t=1560502
    Re: Wicd + WPA = Connection Failed, Bad Password?

    That fix didn't work for me.

    What worked for me was uninstalling network-manager and network-manager-gnome and then rebooting.

    I have all above problems. I posted here to share it may save you a lot of time. Sometimes we forget how to upgrade if it was done last year so this post will help for anyone owns a tablet Herotab C8 or Novo 7 Advanced, both of them are ok to use. Herotab C8 has problem with wifi I basically sit in the same room for it to work but it has its own reset button make the upgrade easy but it only has one camera at the front but it is heavy but a solid tablet. Novo7 has both front and back camera but it is not solid as Herotab. Both of tablets have a problem with the battery, they won't last long. They are good for experience since they are so cheap and Android, I am using them to lean and develop Android it is the same that we learn Linux before.

    There is no much different from 2.3 to 4.0.3 basically the same except the layout and more stable just a bit/less CPU resource just a bit. I am disappointed on Google for this ICS 4.0.3  release. They should implement something brand new like peek/hub/flow concept of Blackberry 10. I have my phone 2.3 and will keep as it is. Most people thinks that Android is always having the problem because the apps are running Java. I agree Java is slow because it is interpret languages through JVM....so maybe no need to upgrade I see no different from ver. 2.3 to 4.0.3 except some cool layouts. 

     

    Wednesday, September 26, 2012

    Document with Scribd is better Google docs

    If you are the user want to read a document from this blog and if it is stored in google docs you can link with the document but the user needs to login to read the document. With Scribd you don't need it displays as it is. For example my test code doc. Just need go to HTML instead of compose and paste the Embed code into the blog like add youtube video. At Scribd select HTML for embed. To display tablet or Smartphone needs flash and it comes on the old version of Dolphin < 8.5, the new version will no longer support flash.
    http://forum.xda-developers.com/showthread.php?t=1787595
    Test Code Result

    My New System

    I can do more things and faster with my new system it is i7
    Acer Aspire Desktop Computer featuring Intel Core i7-2600 Processor (AM3970-EB12P)
    I know ACER is not that good but it is on sale for $649.00. At work I am using the same system i7 with 32 GB of RAM and I fall in love with the machine this is the reason I bought this machine. At work the linux kernel compile time for the target is reducing from 2 hours to 30 minutes. This system is only 8 GB of RAM can be upgraded to 16 GB. I will even do it later ideally 16 GB is the best but wait to make some money first. I can run 2 VMware and VirtualBox and Photoshop...it is great machine except it is ACER hope that it will last for 2 years, my last ACER monitor was only last for 2 years and died.
      

    It came with 1.5 T so I am using 600 for C drive using win 7 with VMware. I was using VirtualBox and start using VMware for the new project which I find VMware is better performance than Virtualbox but Virtualbox offers many tools to convert or clone hard drive. The new system I am using VMware and my old system is using Virtualbox. No need for dualboot machine everything runs from Win 7 as Host since win 7 is much stable now. All linux systems run as Guest. It makes like more easy now with the fast system I just bought. For some reasons I have a Quad AMD 2.4 GHz it runs slow like hell compare to this system i7 this is other reason I bought this system. I built my old system last year for about $350, it is no good to build it is much better to buy the system when it is on sale. To build the system sometimes end up costs more than buy the system when it is on sale.
    The new system goes well with 24" inches SamSung S24B350H Monitor for $199, 1/2 of the screen is using for windows and 1/2 of screen is using for linux. With the set of wireless keyboard and mouse from Logitech I am using EX100 wireless keyboard + mouse.  The ACER's keyboard comes with the system is sucked it is small like laptop keyboard, cannot use for the real work. From the net people tells the same thing. This machine also has a lot of USB ports from and back and Multi-in-1 Card Reader which makes so easy to take pictures and upload into the blog.

    http://www.bestbuy.ca/en-CA/product/acer-acer-aspire-desktop-computer-featuring-intel-core-i7-2600-processor-am3970-eb12p-am3970-eb12p/10190543.aspx?path=153d5544e3b964502ef2ad79b07960dden02

    http://www.samsung.com/sg/consumer/pc-peripherals-printer/monitor/led-monitor/LS24B350HS/XS

    http://flexequinox.blogspot.ca/2012/09/how-to-bridge-networking-in-vmware.html

    http://flexequinox.blogspot.ca/2012/09/how-to-bridge-networking-in-vmware.html

    GParted to resize your existing hard drive

    I am using VMware as my Virtual Disk but it is the same as standalone or dualboot machines.
    First you need to ISO image I am using linuxmint-13-cinnamon-dvd-64bit.iso which can be downloaded from Linux Mint. You cannot resize the hard driver unless you load from LiveCD or ISO image. i.e.
    kubuntu-14.04-desktop-amd64.iso. VMware setting and expand the hard drive you want it.

    You need to hit F2 to go to BIOS setup and setup CD as 1st boot. In VMware there are 2 variables on VMX file locates in your Virtual Machines -> Name of  your Virtual Machine.VMX.
    If these variables are exist you can add as follow to let VMware knows. The string name are exactly as you see.
    bios.bootDelay = "5000"
    bios.forceSetupOnce = "TRUE"
    The 1st option delay boot time so you have enough time to hit F2 and 2nd option it boots into BIOS or ESC to choose the device to boot up. This is one time boot selection.

    This is BIOS of VMware and not BIOS of the system. VMware creates a BIOS similar to BIOS system to handle Boot and other things. VMware using PhoenixBIOS. My system BIOS is ACER.
    To distinguish between 2 BIOS. I call system BIOS and VMware BIOS.
    When load into this VMware BIOS you need to change CD/DVD file points to ISO that you want to run.
    With the virtual machine powered off, open the Configuration Editor (choose Settings then Configuration Editor), and select the DVD/CD-ROM. If not, it won't boot from this iso even you hit ESC to choose CD/DVD boot. This is a virtual CD/DVD drive not physical CD drive !!!. no need to put CD in the physical drive if choose ISO option instead of physical drive. The default of ISO image is pointing to C:/Program Files(X86)/VMware Player/linux.iso all you need to point this to right ISO.
    Using edit VMware Hardware then Click on ISO image instead of physical CD/DVD. My case is  linuxmint-13-cinnamon-dvd-64bit.iso the iso just downloaded into Downloads directory.
    In this CD/DVD setup choose use ISO to boot and device status select connect at power on so it can boot.
     Remember the new size is only good to VMware but Linux-Mint won't know until you change the size using GParted. YOU CANNOT RESIZE IF IT BOOTS FROM THE SAME HARD DRIVE for example /dev/sda1 if you drive to resize it will prompt that device is busy it needs to umount first and this is the reason we boot from LiveCS ISO image. After it boots we can go change the hard drive of /dev/sda1 because it is umounted.
    When ISO boot up choose demo and run from there. Do not select installation all we want is to use Gparted.
    If GParted in not installed in this live CD need to install: sudo apt-get install gparted. The ISO is stored from disk or USB, the demo runs from RAM so gparted in run from RAM when it is shut down gparted is gone and it does not write into ISO file. Since the disk expand is rarely using so to issue the command sudo apt-get install gparted is a small thing.

    Ref.
    http://communities.vmware.com/message/1061677 
    http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=102



    This is system BIOS. It is different with VMware BIOS above.
    If you have a problem to install Win 7 with RAID then Disable RAID in BIOS and enabled native IDE.
    RAID (redundant array of independent disks)




    Clone VDI or Convert VDI (Virtualbox) to VMDK (VMware)

    CLONE VDI
    This is the case you want to move VDI to the other machine, Create VM and using existing VDI

    C:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonevdi "C:\Users\HP\VirtualB
    ox VMs\ubuntu1\ubuntu1.vdi" D:\ubuntu1_test.vdi
    0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
    Clone hard disk created in format 'VDI'. UUID: 9199a774-2d26-4a60-b186-63eb2d212
    831

    CONVERT VDI ->VMDSK
    This is when you want to move from Virtual disk from VirtualBox to VMware because the new UUID in the VMware setup create the VMware and choose later option. Then delete the Hard drive and create a new Hard driver with the existing VMDK just converted and select option keep existing format. This way the new UUID of VMDK is created in VMX file. See Ref. 3


    1. http://www.leonardoborda.com/blog/easily-convert-vdi-to-vmdk-images/
    2. http://www.irongeek.com/i.php?page=videos/vmwareplayerlivecd
    3. http://www.aztcs.org/meeting_notes/winhardsig/virtualmachines/vmware/Using_VMDK_File_to_Create_a_VM_in_VMwarePlayer--Windows.pdf

    c:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd J:\ubuntu1_test.vdi J:
    \ubuntu1_test.vmdk --format vmdk
    0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
    Clone hard disk created in format 'vmdk'. UUID: fd4474c9-199f-4a9e-880a-b312ff175e35

    c:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo "j:\ubuntu1_test.vdi"
    UUID:                 9199a774-2d26-4a60-b186-63eb2d212831
    Accessible:           yes
    Logical size:         42756 MBytes
    Current size on disk: 34306 MBytes
    Type:                 normal (base)
    Storage format:       VDI
    Format variant:       dynamic default
    Location:             j:\ubuntu1_test.vdi

    c:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo "j:\ubuntu1_test.vmdk"
    UUID:                 fd4474c9-199f-4a9e-880a-b312ff175e35
    Accessible:           yes
    Logical size:         42756 MBytes
    Current size on disk: 32899 MBytes
    Type:                 normal (base)
    Storage format:       vmdk
    Format variant:       dynamic default
    Location:             J:\ubuntu1_test.vmdk


    Problem: If you are running into GRUB rescue> 

    Then either the VMDK just converted is corrupted or UUID does not match with the new VMDK created.
    If there is an error Syntax error line 1 of VMDK probably something to do with the setup as well.
    In the VMX there are 
    ide1:0.fileName = "\ubuntu1_test.vmdk"
    uuid.location = " make sure it matches with uuid of ubuntu1_test.vmdk"
    uuid.bios = "
    make sure it matches with uuid of ubuntu1_test.vmdk"
    make sure they are matching you can use VBoxManage.exe showhdinfo to get UUID.

    VirtualBox vs. VMware
    VMware performs better Virtualbox. VMware takes less CPU resources than VirtualBox however, for tools as mentioned above, VirtualBox offers more flexible than VMware. I am currently using both VirtualBox and VMware and because it is faster I feel comfortable to use VMware for my future development my trend toward VMware. I have been using VirtualBox everyday for the past 3 years when switch to VMware you definitely see the difference in the performance right away. It is very easy to setup: I have 2 identical virtual disks kubuntu_64.vdi and kubuntu_64.vmdk (using VBoxManage.exe to clonehd) with VirtualBox is running the CPU usage is 50% and with VMware is running the CPU usage is currently 20%. Same hardware and same win 7 is the host. This is how I test. I don't know but this is what I see on my 2 systems: I7@3.4 GHz with 8 GB of RAM and AMD Quad@2.4 GHz with 6 GB of RAM. When it takes less CPU resources you can do more work because you don't have to wait. In order to run VM CPU needs to have VT supported at least Dual Core. 
    Even the size of Virtual disk, VMware takes less space for the same image, the difference is 2 GB.
    Below is some vdi have been converted to vmdk
    09/28/2012  09:59 PM    36,121,522,176 ubuntu1_test.vdi (VirtualBox)
    09/28/2012  09:54 PM    34,666,905,600 ubuntu1_test.vmdk (VMware) 


    09/27/2012  08:48 PM    30,775,869,952 Kubuntu-64bit.vdi (VirtualBox)
    09/27/2012  10:31 PM    28,886,237,184 Kubuntu-64-bit.vmdk (VMware)
    continue 

     

    Tuesday, September 25, 2012