마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

apk URL을 이용하여 자동 다운 및 설치 [closed]

0 추천

안녕하세요

 

버전이 낮을 경우 업그레이드 팝업 버튼을 누르면 URL이 띄워지고 그 URL을 눌러야 다운로드르 시작했습니다.

 

근데 그 URL을 누르는 과정을 없애고 업그레이드 버튼만 누르면 자동으로 다운로드가 되게 하고싶은데요

 

인터넷에 찾아보니까

 

 

public void download_WebLink()
{
try
{   
Log.e("DOWNLOAD", "start");
  
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();   
    urlConnection.setDoOutput(true);   
    urlConnection.connect();
    Log.e("DOWNLOAD", "Connect");
  
    File SDCardRoot = Environment.getExternalStorageDirectory();   
    File file = new File(SDCardRoot,"Geocoder_Test.apk");  
    FileOutputStream fileOutput = new FileOutputStream(file);
    Log.e("DOWNLOAD", "fileoutput");
  
    InputStream inputStream = urlConnection.getInputStream();   
    int totalSize = urlConnection.getContentLength();   
    int downloadedSize = 0;   
  
    byte[] buffer = new byte[1024];   
    int bufferLength = 0; 
    while ( (bufferLength = inputStream.read(buffer)) > 0 ) 
    {   
        fileOutput.write(buffer, 0, bufferLength);   
        downloadedSize += bufferLength;
        //mProgressBar.setProgress(downloadedSize);
        Log.e("DOWNLOAD", "saving...");
    }   
    fileOutput.close();   
  
} catch (MalformedURLException e) 
{   
    e.printStackTrace();   
} catch (IOException e) 
{   
    e.printStackTrace();   
Log.e("DOWNLOAD", "end");
 
Log.e("DOWNLOAD", "InstallAPK Method Called");
installAPK();
}
 
이런 코드가 있더라구요
 
저기서 저 URL만 바꾸면 되나요?
 
흠..했는데 자꾸 앱이 죽어서..
 
 

 

질문을 종료한 이유: 56565656565656
윤둥이 (4,560 포인트) 님이 2013년 5월 14일 질문
윤둥이님이 2013년 5월 14일 closed
...