|
46 | 46 | import android.content.Intent;
|
47 | 47 | import android.content.SharedPreferences;
|
48 | 48 | import android.graphics.Color;
|
| 49 | +import android.net.Uri; |
| 50 | +import android.os.Build; |
49 | 51 | import android.os.Handler;
|
50 | 52 | import android.os.HandlerThread;
|
51 | 53 | import android.preference.PreferenceManager;
|
| 54 | +import android.provider.Settings; |
52 | 55 |
|
53 | 56 | import androidx.core.app.NotificationCompat;
|
54 | 57 |
|
@@ -164,25 +167,36 @@ private void showPersistentNotification() {
|
164 | 167 | manager.createNotificationChannel(chan);
|
165 | 168 | }
|
166 | 169 |
|
| 170 | + // intent to redirect to notificaition ettings |
| 171 | + /*Intent notificationIntent; |
| 172 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { |
| 173 | + notificationIntent = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS); |
| 174 | + notificationIntent.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); |
| 175 | + notificationIntent.putExtra(Settings.EXTRA_CHANNEL_ID, NOTIFICATION_CHANNEL_ID); |
| 176 | + notificationIntent.putExtra("app_package", getPackageName()); |
| 177 | + notificationIntent.putExtra("app_uid", getApplicationInfo().uid); |
| 178 | + notificationIntent.putExtra("android.provider.extra.APP_PACKAGE", getPackageName()); |
| 179 | + } else { |
| 180 | + notificationIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); |
| 181 | + notificationIntent.setData(Uri.parse("package:" + getPackageName())); |
| 182 | + } |
| 183 | + PendingIntent notificationPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE);*/ |
| 184 | + |
| 185 | + |
167 | 186 | Intent appIntent = new Intent(this, ActivityMain.class);
|
168 | 187 | appIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
169 | 188 | PendingIntent appIntentRedirect = PendingIntent.getActivity(this, 0, appIntent, PendingIntent.FLAG_IMMUTABLE);
|
170 | 189 |
|
171 |
| - Intent notificationIntent = new Intent(); |
172 |
| - notificationIntent.setAction("android.settings.APP_NOTIFICATION_SETTINGS"); |
173 |
| - notificationIntent.putExtra("app_package", getPackageName()); |
174 |
| - notificationIntent.putExtra("app_uid", getApplicationInfo().uid); |
175 |
| - PendingIntent notificationIntentRedirect = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_IMMUTABLE); |
176 |
| - |
177 | 190 | Notification notification = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
|
178 |
| - .setOngoing(true) |
| 191 | + .setOngoing(false) |
179 | 192 | .setSmallIcon(R.drawable.ic_stat)
|
180 | 193 | .setContentTitle(getString(R.string.app_is_running))
|
181 |
| - .setContentText(getString(R.string.agent_description)) // Add a short text |
| 194 | + .setContentText(getString(R.string.agent_description)) |
182 | 195 | .setCategory(Notification.CATEGORY_SERVICE)
|
| 196 | + .setPriority(NotificationCompat.PRIORITY_DEFAULT) |
183 | 197 | .setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.app_is_running_extend)))
|
184 | 198 | .setContentIntent(appIntentRedirect)
|
185 |
| - .addAction(R.drawable.ic_about, getString(R.string.disable_notification), notificationIntentRedirect) |
| 199 | + //.addAction(R.drawable.ic_stat, getString(R.string.disable_notification), notificationPendingIntent) |
186 | 200 | .build();
|
187 | 201 |
|
188 | 202 | int notificationId = 1;
|
|
0 commit comments