Browse Source

Réglage optimisation battery

pull/1/head
Samuel Vermeulen 5 months ago
parent
commit
20781e17de
  1. 1
      app/src/main/AndroidManifest.xml
  2. 18
      app/src/main/java/fr/svpro/radiomercure/MainActivity.java

1
app/src/main/AndroidManifest.xml

@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<application

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

@ -9,12 +9,13 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.IBinder;
import android.os.PowerManager;
import android.provider.Settings;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.CookieManager;
@ -52,10 +53,19 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//-------------A revoir-----------//
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//--------------------------------//
//Réglage de l'app battery non optimisée par l'utilisateur
PowerManager powerManager = (PowerManager) getApplicationContext().getSystemService(POWER_SERVICE);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Intent intent = new Intent();
if (!powerManager.isIgnoringBatteryOptimizations(getApplication().getPackageName())) {
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
//intent.setData(Uri.parse("package:"+ getApplicationInfo().packageName));
startActivity(intent);
}
}
//WebBiew affichage du site
web = findViewById(R.id.wv);
web.setWebViewClient(new WebViewClient());
web.getSettings().setUserAgentString("Mozilla/5.0 "+ getApplicationInfo().packageName);

Loading…
Cancel
Save