private void startSlave(String passingText){
Intent intent = new Intent();
intent.setClassName(PACKAGE_NAME, CLASS_NAME);
Bundle bundle = new Bundle();
bundle.putString("key", passingText);
intent.putExtras(bundle);
//check if the slave app installed
List<ResolveInfo> list = getPackageManager().queryIntentActivities(
intent,
PackageManager.MATCH_DEFAULT_ONLY);
if (list.size() >0 ){
//Yes, the Slave App installed
startActivity(intent);
}else{
//No!
Toast.makeText(AndroidMasterActivity.this,
"Slave App not yet installed!",
Toast.LENGTH_LONG).show();
}
}
Check if a app is instlled
In the last two posts Start a specified app and Start a specified app with data passed, it's assumed that the slave app is installed. In order to check if it's installed, we can call PackageManager.queryIntentActivities().
0 Response to "Check if a app is instlled"
Posting Komentar