Tag: Io Div CTI new SP on res C
Determine whether a package exists in the system (from the network). After testing, it is easy to use:
Public Boolean checkbrowser (string packagename ){
If (packagename = NULL | "". Equals (packagename ))
Return false;
Try {
Applicationinfo info = getpackagemanager (). getapplicationinfo (
Packagename, packagemanager. get_uninstalled_packages );
Return true;
} Catch (namenotfoundexception e ){
Return false;
}
}
It is tested to determine whether an activity exists in the system (from the network:
Intent intent = new intent ();
Intent. setclassname ("package name", "package name. Activity name ");
If (getpackagemanager (). resolveactivity (intent, 0) = NULL ){
// This activity does not exist in the system
// After testing, the activity that is not in the system is indeed executed here
}
Else
{
// Some activities are actually executed here.
}
Note: after testing, the result of judging the self-contained package in this program is certainly exists and can only be used to determine the packages outside the program.
Public Boolean checkbrowser (string packagename) {If (packagename = NULL | "". equals (packagename) return false; try {applicationinfo info = getpackagemanager (). getapplicationinfo (packagename, packagemanager. get_uninstalled_packages); Return true;} catch (namenotfoundexception e) {return false ;}}