deprecated
This commit is contained in:
parent
cd57ea3243
commit
d0e87b7258
@ -7,6 +7,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -21,19 +22,19 @@ public class DownLoadBroadcastReceiver extends BroadcastReceiver {
|
||||
Intent install = new Intent(Intent.ACTION_VIEW);
|
||||
DownloadManager.Query queryById = new DownloadManager.Query();
|
||||
queryById.setFilterById(currentDownloadId);
|
||||
Cursor downloadCursor = downloadManager.query(queryById);
|
||||
Cursor cursor = downloadManager.query(queryById);
|
||||
String filePath = null;
|
||||
if(downloadCursor.moveToFirst()){
|
||||
if(downloadCursor.getInt(downloadCursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_SUCCESSFUL){
|
||||
int fileNameIdx = downloadCursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_FILENAME);
|
||||
filePath = downloadCursor.getString(fileNameIdx);
|
||||
if(cursor.moveToFirst()){
|
||||
if(cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)) == DownloadManager.STATUS_SUCCESSFUL){
|
||||
filePath = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI));
|
||||
}else{
|
||||
downloadManager.remove(currentDownloadId);
|
||||
downloadCursor.close();
|
||||
cursor.close();
|
||||
return;
|
||||
}
|
||||
downloadCursor.close();
|
||||
cursor.close();
|
||||
}
|
||||
Log.i("FilePath",filePath);
|
||||
if(filePath == null) return;
|
||||
File file = new File(filePath);
|
||||
install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
|
||||
|
Loading…
x
Reference in New Issue
Block a user