我正在创建一个应用程序。在这个应用程序中当用户注册所有该用户的联系人时将被邀请。我的问题是x有两个数字y说y1和y2.When x发送邀请y和y安装我的应用程序他/她的手机号码是y1.A之后不应该从x而是从他的任何联系人那里得到任何邀请。如何实现这一目标?
答案 0 :(得分:2)
尝试使用该代码来了解您的应用是否已安装
boolean isAppInstalled = appInstalledOrNot("com.check.application");
if(isAppInstalled) {
//This intent will help you to launch if the package is already installed
Intent LaunchIntent = getPackageManager()
.getLaunchIntentForPackage("com.check.application");
startActivity(LaunchIntent);
Log.i("Application is already installed.");
} else {
// Do whatever we want to do if application not installed
// For example, Redirect to play store
Log.i("Application is not currently installed.");
}
}
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
}
return false;
}