How do I keep device screen awake

280 views
Skip to first unread message

Michael Tawiah Sowah

unread,
Dec 10, 2017, 5:21:53 PM12/10/17
to Flutter Dev
How do I keep device screen awake after my app starts?

mr...@google.com

unread,
Dec 11, 2017, 4:13:39 AM12/11/17
to Flutter Dev
I am not aware of this functionality being exposed through the Flutter SDK (I may be wrong).

If I'm right, you need to write platform-specific code. E.g. add

    [[UIApplication sharedApplication] setIdleTimerDisabled:YES];

to your AppDelegate.m and

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

to your MainActivity.java.

Michael Tawiah Sowah

unread,
Dec 11, 2017, 4:43:02 AM12/11/17
to Flutter Dev
thanks and how about disabling the hardware back button completely for the entire app

Mikkel Ravn

unread,
Dec 11, 2017, 5:33:03 AM12/11/17
to Michael Tawiah Sowah, Flutter Dev
Override MainActivity.onBackPressed with an empty method?

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mikkel Nygaard Ravn
Software Engineer

Michael Tawiah Sowah

unread,
Dec 11, 2017, 7:23:28 AM12/11/17
to Flutter Dev
I don't get you


On Monday, December 11, 2017 at 10:33:03 AM UTC, Mikkel Ravn wrote:
Override MainActivity.onBackPressed with an empty method?
On Mon, Dec 11, 2017 at 10:43 AM, Michael Tawiah Sowah <michael...@gmail.com> wrote:
thanks and how about disabling the hardware back button completely for the entire app


On Monday, December 11, 2017 at 9:13:39 AM UTC, mr...@google.com wrote:
I am not aware of this functionality being exposed through the Flutter SDK (I may be wrong).

If I'm right, you need to write platform-specific code. E.g. add

    [[UIApplication sharedApplication] setIdleTimerDisabled:YES];

to your AppDelegate.m and

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

to your MainActivity.java.

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Mikkel Ravn

unread,
Dec 11, 2017, 7:33:08 AM12/11/17
to Michael Tawiah Sowah, Flutter Dev
In your_project/android/app/src/main/java/com/yourcompany/yourproject/MainActivity.java:

public class MainActivity extends FlutterActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GeneratedPluginRegistrant.registerWith(this);
  }

  @Override
  public void onBackPressed() {
    // do nothing, disables back button
  }
}


To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Tawiah Sowah

unread,
Dec 11, 2017, 8:57:12 AM12/11/17
to Flutter Dev
Thanks so much... How do pass data through Navigator.of(context).pushNamed('/conta')

Seth Ladd

unread,
Dec 11, 2017, 11:39:35 AM12/11/17
to Michael Tawiah Sowah, Flutter Dev, Ian Hickson
+ Ian

On Mon, Dec 11, 2017 at 5:57 AM, Michael Tawiah Sowah <michael...@gmail.com> wrote:
Thanks so much... How do pass data through Navigator.of(context).pushNamed('/conta')

This is a FAQ, something we get asked about a lot.


@Ian, I wonder if we could do something like this:

pushNamed('/something', dynamic params)

 
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

Michael Tawiah Sowah

unread,
Dec 11, 2017, 11:55:27 AM12/11/17
to Flutter Dev
that would be great and cleaner

Ian Hickson

unread,
Dec 11, 2017, 2:02:41 PM12/11/17
to Seth Ladd, Michael Tawiah Sowah, Flutter Dev
This is on our radar; you can track it at https://github.com/flutter/flutter/issues/6225
--
Ian Hickson

Michael Tawiah Sowah

unread,
Dec 11, 2017, 3:50:17 PM12/11/17
to Flutter Dev
so in the meantime how do I pass data to the next page....
Ian Hickson

Mikkel Ravn

unread,
Dec 11, 2017, 3:53:54 PM12/11/17
to Michael Tawiah Sowah, Flutter Dev
I suppose you could just store the data to pass in a sufficiently accessible variable (e.g. a global one).

To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Michael Tawiah Sowah

unread,
Dec 11, 2017, 4:00:45 PM12/11/17
to Flutter Dev
Reply all
Reply to author
Forward
0 new messages