In my android application I need to get the version of the application programatically. But whenever I try with this code it crashes at this line. Is there anything that I am missing
PackageInfo pinfo = getPackageManager().getPackageInfo(
this.getPackageName(), 0);
I tried getting it from PackageManager and PackageInfo. In both the cases the application crashes and launches ViewRoot.handleMessage and I get a message “Source Not found”
Please try below function.