未安装的应用程序 [英] Application not installed

查看:141
本文介绍了未安装的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下载文件已经成功,但安装时有一个错误应用程序未安装
我已经使用INSTALL_NON_MARKET_APPS许可
安装提示已经存在,但每次我试过了,它总是应用程序未安装的错误。

Download file already success but when install it has an error "application-not-installed" I already use INSTALL_NON_MARKET_APPS permission Install prompt already there but everytime I tried , it's always "application-not-installed" error.

public void Update(String apkurl){
    try {
          URL url = new URL(apkurl); 
          HttpURLConnection c = (HttpURLConnection) url.openConnection();
          c.setRequestMethod("GET");
          c.setDoOutput(true);
          try{
          c.connect();
          } catch (Exception e) {
              Toast.makeText(getApplicationContext(),e.getMessage() , Toast.LENGTH_LONG).show();
          }
          String PATH = Environment.getExternalStorageDirectory() + "/download/";
          File file = new File(PATH);
          file.mkdirs();
          File outputFile = new File(file, "prov1.apk");
          FileOutputStream fos = new FileOutputStream(outputFile);

          InputStream is = c.getInputStream();

          byte[] buffer = new byte[1024];
          int len1 = 0; 
          while ((len1 = is.read(buffer)) != -1) {
              fos.write(buffer, 0, len1);
          } 
          fos.close();
          is.close();//till here, it works fine - .apk is download to my sdcard in download file

          Intent intent = new Intent(Intent.ACTION_VIEW);  
          intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

          intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "prov1.apk")), "application/vnd.android.package-archive");

          startActivity(intent);   

      } catch (IOException e) {
          Toast.makeText(getApplicationContext(), "Update error!", Toast.LENGTH_LONG).show();
      }
}  

我已经看过这个话题,但仍卡住另一个问题。我真的很感谢你的帮助。

I already read another question about this topic but still stuck. I am really thank for your help.

推荐答案

的问题之一可能是因为你已经有一些应用程序使用相同的包名。
例如,如果你尝试安装com.something.prov1它可能已经存在同一个包。如果这是不是先卸载应用程序的情况下

One of the problems it could be that you already have some app with the same package name. For example if you try to install com.something.prov1 the same package it might already exist. if that is the case than first uninstall the app

adb uninstall com.something.prov1

这篇关于未安装的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆