Fixed crashes when uploads or downloads are inserted in the notification bar (Android...
authorDavid A. Velasco <dvelasco@solidgear.es>
Tue, 19 Jun 2012 09:05:00 +0000 (11:05 +0200)
committerDavid A. Velasco <dvelasco@solidgear.es>
Tue, 19 Jun 2012 09:05:00 +0000 (11:05 +0200)
src/eu/alefzero/owncloud/files/services/FileDownloader.java
src/eu/alefzero/owncloud/files/services/FileUploader.java

index cc13a67..c051fc1 100644 (file)
@@ -124,6 +124,9 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);\r
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, mTotalDownloadSize == -1);\r
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);\r
         mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);\r
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, mTotalDownloadSize == -1);\r
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);\r
+        // dvelasco ; contentIntent MUST be assigned to avoid app crashes in versions previous to Android 4.x ;\r
+        //              BUT an empty Intent is not a very elegant solution; something smart should happen when a user 'clicks' on a download in the notification bar\r
+        mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);\r
         \r
         mNotificationMngr.notify(1, mNotification);\r
 \r
         \r
         mNotificationMngr.notify(1, mNotification);\r
 \r
index ee63d8b..a55675d 100644 (file)
@@ -16,6 +16,7 @@ import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.accounts.AccountManager;
 import android.app.Notification;
 import android.app.NotificationManager;
+import android.app.PendingIntent;
 import android.app.Service;
 import android.content.Intent;
 import android.net.Uri;
 import android.app.Service;
 import android.content.Intent;
 import android.net.Uri;
@@ -148,7 +149,10 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, false);
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
         mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, false);
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
-
+        // dvelasco ; contentIntent MUST be assigned to avoid app crashes in versions previous to Android 4.x ;
+        //              BUT an empty Intent is not a very elegant solution; something smart should happen when a user 'clicks' on an upload in the notification bar
+        mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
+        
         mNotificationManager.notify(42, mNotification);
 
         WebdavClient wc = new WebdavClient(ocUri);
         mNotificationManager.notify(42, mNotification);
 
         WebdavClient wc = new WebdavClient(ocUri);