From 539ca8d4f2270680b65f5d203992a74818798095 Mon Sep 17 00:00:00 2001 From: fysx Date: Sun, 23 Feb 2014 14:51:33 +0100 Subject: [PATCH] fixed opening of .love files when URL is entered in Chrome --- AndroidManifest.xml | 101 ++++++++++---------- src/org/love2d/android/DownloadService.java | 15 ++- 2 files changed, 64 insertions(+), 52 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index bdf1a5f9..2e13476d 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -9,55 +9,60 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + android:screenOrientation="landscape" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/org/love2d/android/DownloadService.java b/src/org/love2d/android/DownloadService.java index b15ff2b3..8bfd3fa4 100644 --- a/src/org/love2d/android/DownloadService.java +++ b/src/org/love2d/android/DownloadService.java @@ -22,7 +22,7 @@ public class DownloadService extends IntentService { @Override public void onDestroy() { - Log.d("DownloadService", "ending"); + Log.d("DownloadService", "destroying"); unregisterReceiver(downloadReceiver); } @@ -33,7 +33,7 @@ public class DownloadService extends IntentService { String url = intent.getStringExtra("url"); Uri uri = Uri.parse(url); - Log.d("DownloadActivity", "Downloading from url: " + url + "file = " + uri.getLastPathSegment()); + Log.d("DownloadService", "Downloading from url: " + url + "file = " + uri.getLastPathSegment()); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setDescription("LÖVE Game Download"); @@ -42,8 +42,8 @@ public class DownloadService extends IntentService { // in order for this if to run, you must use the android 3.2 to compile your app if (Build.VERSION.SDK_INT >= 11) { - request.allowScanningByMediaScanner(); - request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); + DownloadRequestSettings_API11 settings = new DownloadRequestSettings_API11(); + settings.setup (request); } request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, uri.getLastPathSegment()); // get download service and enqueue file @@ -87,3 +87,10 @@ public class DownloadService extends IntentService { } }; } + +class DownloadRequestSettings_API11 { + public static void setup (DownloadManager.Request request) { + request.allowScanningByMediaScanner(); + request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); + } +}