Browse Source

Optimisation

pull/1/head
Samuel Vermeulen 5 months ago
parent
commit
df73c3dd0e
  1. 18
      app/src/main/java/fr/svpro/radiomercure/MainActivity.java
  2. 5
      app/src/main/java/fr/svpro/radiomercure/MediaPlayerService.java

18
app/src/main/java/fr/svpro/radiomercure/MainActivity.java

@ -7,7 +7,6 @@ import android.app.Dialog;
import android.app.DownloadManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
@ -56,35 +55,32 @@ public class MainActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Demande d'autorisation de désactiver l'optimisation de la batterie
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.dialog_battery_msg)
//------Demande d'autorisation de désactiver l'optimisation de la batterie------//
AlertDialog.Builder dialogOptBattery = new AlertDialog.Builder(this);
dialogOptBattery.setMessage(R.string.dialog_battery_msg)
.setTitle(R.string.dialog_battery_titre);
builder.setPositiveButton(R.string.dialog_button_oui, (dialog12, id) -> {
dialogOptBattery.setPositiveButton(R.string.dialog_button_oui, (dialog12, id) -> {
Intent intent = new Intent();
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
//intent.setData(Uri.parse("package:"+ getApplicationInfo().packageName));
startActivity(intent);
});
builder.setNegativeButton(R.string.dialog_button_non, (dialog1, id) -> {
dialogOptBattery.setNegativeButton(R.string.dialog_button_non, (dialog1, id) -> {
// User cancelled the dialog
Toast.makeText(this, "Annulation par l'utilisateur", Toast.LENGTH_SHORT).show();
});
AlertDialog alertDialog = builder.create();
AlertDialog alertDialog = dialogOptBattery.create();
PowerManager powerManager = (PowerManager) getApplicationContext().getSystemService(POWER_SERVICE);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!powerManager.isIgnoringBatteryOptimizations(getApplication().getPackageName())) {
alertDialog.show();
}
}
//------------------------------------------------------------------------------------------------//
//WebBiew affichage du site
web = findViewById(R.id.wv);

5
app/src/main/java/fr/svpro/radiomercure/MediaPlayerService.java

@ -1,9 +1,6 @@
package fr.svpro.radiomercure;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
@ -14,10 +11,8 @@ import android.os.IBinder;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Menu;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import java.io.IOException;

Loading…
Cancel
Save