Ignore Battery Optimization for radio application










0















When my online radio application goes in doze mode there is no network access because of which the radio stops working.Even the wake locks don't work in doze mode.
I've added the intent as per qouted in documentation.




An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can
trigger a system dialog to let the user add the app to the whitelist
directly, without going to settings. The app fires a
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the
dialog.




Here is the intent.



Intent myIntent = new Intent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
myIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
myIntent.setData(Uri.parse("package:" + getPackageName()));
startActivity(myIntent);



also i have added permission in manifest because the intent is not working without it.
Is it safe to use this permission in a radio application?










share|improve this question

















  • 1





    you have to implement a foreground service to prevent your app from being killed

    – Vladyslav Matviienko
    Nov 14 '18 at 8:22











  • i used background service for playing music in background. But this doze mode behavior is in Android 6.0 and above only. @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:24






  • 1





    you need not a background service, but foreground?

    – Vladyslav Matviienko
    Nov 14 '18 at 8:28











  • ok so foreground services are not affected by doze mode? @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:50











  • it does not let device to enter doze mode while the foreground service is running

    – Vladyslav Matviienko
    Nov 14 '18 at 9:01















0















When my online radio application goes in doze mode there is no network access because of which the radio stops working.Even the wake locks don't work in doze mode.
I've added the intent as per qouted in documentation.




An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can
trigger a system dialog to let the user add the app to the whitelist
directly, without going to settings. The app fires a
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the
dialog.




Here is the intent.



Intent myIntent = new Intent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
myIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
myIntent.setData(Uri.parse("package:" + getPackageName()));
startActivity(myIntent);



also i have added permission in manifest because the intent is not working without it.
Is it safe to use this permission in a radio application?










share|improve this question

















  • 1





    you have to implement a foreground service to prevent your app from being killed

    – Vladyslav Matviienko
    Nov 14 '18 at 8:22











  • i used background service for playing music in background. But this doze mode behavior is in Android 6.0 and above only. @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:24






  • 1





    you need not a background service, but foreground?

    – Vladyslav Matviienko
    Nov 14 '18 at 8:28











  • ok so foreground services are not affected by doze mode? @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:50











  • it does not let device to enter doze mode while the foreground service is running

    – Vladyslav Matviienko
    Nov 14 '18 at 9:01













0












0








0








When my online radio application goes in doze mode there is no network access because of which the radio stops working.Even the wake locks don't work in doze mode.
I've added the intent as per qouted in documentation.




An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can
trigger a system dialog to let the user add the app to the whitelist
directly, without going to settings. The app fires a
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the
dialog.




Here is the intent.



Intent myIntent = new Intent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
myIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
myIntent.setData(Uri.parse("package:" + getPackageName()));
startActivity(myIntent);



also i have added permission in manifest because the intent is not working without it.
Is it safe to use this permission in a radio application?










share|improve this question














When my online radio application goes in doze mode there is no network access because of which the radio stops working.Even the wake locks don't work in doze mode.
I've added the intent as per qouted in documentation.




An app holding the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission can
trigger a system dialog to let the user add the app to the whitelist
directly, without going to settings. The app fires a
ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Intent to trigger the
dialog.




Here is the intent.



Intent myIntent = new Intent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
myIntent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
myIntent.setData(Uri.parse("package:" + getPackageName()));
startActivity(myIntent);



also i have added permission in manifest because the intent is not working without it.
Is it safe to use this permission in a radio application?







android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 8:12









MahamMaham

459




459







  • 1





    you have to implement a foreground service to prevent your app from being killed

    – Vladyslav Matviienko
    Nov 14 '18 at 8:22











  • i used background service for playing music in background. But this doze mode behavior is in Android 6.0 and above only. @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:24






  • 1





    you need not a background service, but foreground?

    – Vladyslav Matviienko
    Nov 14 '18 at 8:28











  • ok so foreground services are not affected by doze mode? @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:50











  • it does not let device to enter doze mode while the foreground service is running

    – Vladyslav Matviienko
    Nov 14 '18 at 9:01












  • 1





    you have to implement a foreground service to prevent your app from being killed

    – Vladyslav Matviienko
    Nov 14 '18 at 8:22











  • i used background service for playing music in background. But this doze mode behavior is in Android 6.0 and above only. @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:24






  • 1





    you need not a background service, but foreground?

    – Vladyslav Matviienko
    Nov 14 '18 at 8:28











  • ok so foreground services are not affected by doze mode? @VladyslavMatviienko

    – Maham
    Nov 14 '18 at 8:50











  • it does not let device to enter doze mode while the foreground service is running

    – Vladyslav Matviienko
    Nov 14 '18 at 9:01







1




1





you have to implement a foreground service to prevent your app from being killed

– Vladyslav Matviienko
Nov 14 '18 at 8:22





you have to implement a foreground service to prevent your app from being killed

– Vladyslav Matviienko
Nov 14 '18 at 8:22













i used background service for playing music in background. But this doze mode behavior is in Android 6.0 and above only. @VladyslavMatviienko

– Maham
Nov 14 '18 at 8:24





i used background service for playing music in background. But this doze mode behavior is in Android 6.0 and above only. @VladyslavMatviienko

– Maham
Nov 14 '18 at 8:24




1




1





you need not a background service, but foreground?

– Vladyslav Matviienko
Nov 14 '18 at 8:28





you need not a background service, but foreground?

– Vladyslav Matviienko
Nov 14 '18 at 8:28













ok so foreground services are not affected by doze mode? @VladyslavMatviienko

– Maham
Nov 14 '18 at 8:50





ok so foreground services are not affected by doze mode? @VladyslavMatviienko

– Maham
Nov 14 '18 at 8:50













it does not let device to enter doze mode while the foreground service is running

– Vladyslav Matviienko
Nov 14 '18 at 9:01





it does not let device to enter doze mode while the foreground service is running

– Vladyslav Matviienko
Nov 14 '18 at 9:01












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295611%2fignore-battery-optimization-for-radio-application%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53295611%2fignore-battery-optimization-for-radio-application%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3