android: frontend: Fix several issues with running notification.

- Priority should be low without sound/vibration.
- Notification should restore app.
This commit is contained in:
bunnei 2019-09-01 03:32:41 -04:00
parent a891f3376b
commit ab55751b4a
3 changed files with 14 additions and 5 deletions

View File

@ -58,7 +58,8 @@
<activity
android:name=".activities.EmulationActivity"
android:theme="@style/CitraEmulation"/>
android:theme="@style/CitraEmulation"
android:launchMode="singleInstance"/>
<activity
android:name=".activities.CustomFilePickerActivity"

View File

@ -24,9 +24,10 @@ public class CitraApplication extends Application {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.app_notification_channel_name);
String description = getString(R.string.app_notification_channel_description);
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel(getString(R.string.app_notification_channel_id), name, importance);
NotificationChannel channel = new NotificationChannel(getString(R.string.app_notification_channel_id), name, NotificationManager.IMPORTANCE_LOW);
channel.setDescription(description);
channel.setSound(null, null);
channel.setVibrationPattern(null);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);

View File

@ -2,6 +2,7 @@ package org.citra.citra_android.activities;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
@ -137,12 +138,18 @@ public final class EmulationActivity extends AppCompatActivity {
}
private void showRunningNotification() {
// Intent is used to resume emulation if the notification is clicked
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, EmulationActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, getString(R.string.app_notification_channel_id))
.setSmallIcon(R.drawable.ic_stat_notification_logo)
.setContentTitle(getString(R.string.app_name))
.setContentText(getString(R.string.app_notification_running))
.setPriority(NotificationCompat.PRIORITY_MIN)
.setOngoing(true);
.setPriority(NotificationCompat.PRIORITY_LOW)
.setVibrate(null)
.setSound(null)
.setContentIntent(contentIntent);
NotificationManagerCompat.from(this).notify(EMULATION_RUNNING_NOTIFICATION, builder.build());
}