我必须下载一个演示apk。我正在使用 php 在数据库中插入一些值。但在某些时候它会引发错误
org.json.JSONException: Value at validity_days of type java.lang.String cannot be converted to int
java中的代码片段:
private void upgradeVersion(String apkPath) {
System.out.println("SDCARD path checked5:-"+apkPath);
if(saveUserInfo()==true)
{
System.out.println("validity...."+validity);
if (apkPath != null) {
progressDialog.dismiss();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(apkPath)),
"application/vnd.android.package-archive");
intent.putExtra("validity_days", validity);
startActivityForResult(intent, 1);
Toast.makeText(getApplicationContext(),"NetVidya ebook app has been successfully installed.", Toast.LENGTH_LONG).show();
}
}
和php响应:
{"users":[{"status":"added","installeddate":"","active":"Y","validity_days":""}]}
我在这里得到 null 那是你抛出错误。
是否可以在android本身中处理该异常?或者我必须在 php.ini 中进行一些更改。
请建议