In my app Manifest I have declared the use of the permission:
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
and in my code I check if my app can install from unknown sources:
public void reinstallApp(Activity activity, String pathname, int request_code)
{
if (activity.getPackageManager().canRequestPackageInstalls())
{
try
{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(pathname)), "application/vnd.android.package-archive");
activity.startActivityForResult(intent, request_code);
}
catch (Exception e)
{
LogUtilities.show(this, e);
}
}
else
{
activity.startActivity(new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES).setData(Uri.parse(String.format("package:%s", activity.getPackageName()))));
}
}
but the "activity.getPackageManager().canRequestPackageInstalls()" is always returning "false", even if I check the allow install from unknow sources in the selection activity.
What's the issue?