0

我想要 android 2.2 版的第一次安装时间。我已经在 android 2.3 中完成,如何在 android 2.2 中完成这是我的代码

try 
    {
        long installed = context.getPackageManager().getPackageInfo("com.simsys.securex", 0).firstInstallTime;
        String DateTimeStamp=getDate(installed, "dd/MM/yyyy hh:mm:ss");
        String dateTimeSync="Installed_Date:";
        String dateTimeSync2=dateTimeSync.concat(DateTimeStamp);
        TextView txtCurrentTime= (TextView)findViewById(R.id.textViewdatetime);
        txtCurrentTime.setText(dateTimeSync2);
    }
    catch (NameNotFoundException e) 
    {
        e.printStackTrace();
    }
4

1 回答 1

1
PackageManager packageManager = context.getPackageManager();
ApplicationInfo appInfo = packageManager.getApplicationInfo("com.simsys.securex", 0);
String sourceDir= appInfo.sourceDir;
long dateTimeSync= new File(sourceDir).lastModified();
于 2012-08-01T06:59:03.520 回答