안녕하세요
버전이 낮을 경우 업그레이드 팝업 버튼을 누르면 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만 바꾸면 되나요?
흠..했는데 자꾸 앱이 죽어서..