|
@ -16,6 +16,7 @@ import java.io.File; |
|
|
import gr.thmmy.mthmmy.R; |
|
|
import gr.thmmy.mthmmy.R; |
|
|
import mthmmy.utils.Report; |
|
|
import mthmmy.utils.Report; |
|
|
|
|
|
|
|
|
|
|
|
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; |
|
|
import static gr.thmmy.mthmmy.services.DownloadService.ACTION_DOWNLOAD; |
|
|
import static gr.thmmy.mthmmy.services.DownloadService.ACTION_DOWNLOAD; |
|
|
import static gr.thmmy.mthmmy.services.DownloadService.COMPLETED; |
|
|
import static gr.thmmy.mthmmy.services.DownloadService.COMPLETED; |
|
|
import static gr.thmmy.mthmmy.services.DownloadService.EXTRA_DOWNLOAD_ID; |
|
|
import static gr.thmmy.mthmmy.services.DownloadService.EXTRA_DOWNLOAD_ID; |
|
@ -61,22 +62,19 @@ public class Receiver extends BroadcastReceiver { |
|
|
|
|
|
|
|
|
File file = new File(SAVE_DIR, fileName); |
|
|
File file = new File(SAVE_DIR, fileName); |
|
|
if (file.exists()) { |
|
|
if (file.exists()) { |
|
|
// String type = "application/" + extension;
|
|
|
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension( |
|
|
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); |
|
|
MimeTypeMap.getFileExtensionFromUrl(file.getAbsolutePath())); |
|
|
|
|
|
|
|
|
Uri pathUri = Uri.fromFile(file); |
|
|
Intent chooser = new Intent(); |
|
|
Intent chooserIntent = new Intent(Intent.ACTION_VIEW); |
|
|
chooser.setAction(android.content.Intent.ACTION_VIEW); |
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
|
|
chooser.setDataAndType(Uri.fromFile(file), type); |
|
|
Intent chooser = Intent.createChooser(chooserIntent, "Open With..."); |
|
|
chooser.setFlags(FLAG_ACTIVITY_NEW_TASK); |
|
|
intent.setDataAndType(pathUri, type); |
|
|
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
|
|
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, chooser, PendingIntent.FLAG_CANCEL_CURRENT); |
|
|
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, chooser, PendingIntent.FLAG_CANCEL_CURRENT); |
|
|
builder.setContentIntent(pendingIntent); |
|
|
builder.setContentIntent(pendingIntent); |
|
|
} |
|
|
} else |
|
|
else |
|
|
Report.w(TAG, "File doesn't exist."); |
|
|
Report.w(TAG,"File doesn't exist."); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
Notification notification = builder.build(); |
|
|
Notification notification = builder.build(); |
|
|
notificationManager.notify(id, notification); |
|
|
notificationManager.notify(id, notification); |
|
|