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