fixed compilation issue with deprecated setLatestEventInfo in EntryActivity by creating a new Notification instead

used support-v4 NotificationCompat builder for that, did have to upgrade minSdk from 3 to 4 because of that
This commit is contained in:
Hans Cappelle committed 2017-10-08 14:56:32 +02:00
1 parent 8e353b8172
commit 72542af042
3 files changed
+22 -7

No files matched your search

@@ -41,6 +41,7 @@ import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.v4.app.NotificationCompat;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.method.PasswordTransformationMethod;
@@ -228,13 +229,17 @@ public class EntryActivity extends LockCloseHideActivity {
private Notification getNotification(String intentText, int descResId) {
String desc = getString(descResId);
Notification notify = new Notification(R.drawable.notify, desc, System.currentTimeMillis());
Intent intent = new Intent(intentText);
PendingIntent pending = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
notify.setLatestEventInfo(this, getString(R.string.app_name), desc, pending);
// no longer supported for api level >22
// notify.setLatestEventInfo(this, getString(R.string.app_name), desc, pending);
// so instead using compat builder and create new notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
Notification notify = builder.setContentIntent(pending).setContentText(desc).setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.notify).setTicker(desc).setWhen(System.currentTimeMillis()).build();
return notify;
}