A0:  Apply settings to keep the screen active for a while without touching it
نوشته شده توسط : dotnek

In other words, it should be said that when designing and developing the application , it should be designed in such a way that when an application runs on the Android system and can be turned on or active for a certain period of time without touching it. For example, consider a situation where a user is using the Google Maps app while driving and cannot touch the phone screen for a certain period of time, but needs to have the screen turned on to be able to see the app. In this part of the tutorial, we want to increase the duration of the screen being active and on using two different methods.In order to increase the brightness and activation time of the screen while running the application without touching the screen, we must create a project so that we can use it and apply this change in two different ways.1- We create an Android project with the desired name, for example, KeepScreenOn.2- The activity that we should use in this project, it is better to choose it as Empty Activity.3- The language used in this project to do this is Java.

Keep the screen on and off using the first KeepScreenOn method

It should be noted that this method is one of the easiest ways to keep the screen on and active when running the application without touch.KeepScreenOn is located in the XML activity layer.1- We define this feature in the parent view so that the screen is on and active when an application is running .2- The codes that should be in the activity_main.xml section to apply the necessary changes are as follows:

<? xml version = "1.0" encoding = "utf-8"?>
<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"
xmlns: tools = "http://schemas.android.com/tools"
android: layout_width = "match_parent"
android: layout_height = "match_parent"
android: orientation = "vertical"
tools: context = ". MainActivity"
android: KeepScreenOn = "true">

<TextView
android: layout_width = "wrap_content"
android: layout_height = "wrap_content"
android: text = "Hello World!" />

</LinearLayout>
It should be noted that in the code listed above, android: KeepScreenOn is defined with a value of true inside the layout, which makes the screen active and on while the activity is running.

Keep the screen on and off using the second method FLAG_KEEP_SCREEN_ON

In the previous method, by making some changes, we caused the screen to be active and bright while the activity is running, but consider the situation that the user may not have specified the destination and route when navigating, in This mode may cause the screen to turn on and off unnecessarily for no reason, reducing battery life. Therefore, the best way to keep the screen on and active so that we can use the application that is running , we use the second method, which we describe in this part of the tutorial.In this part of the tutorial and the second method, I use the switch buttons to keep the screen on and active. 

 

Read more on:https://www.dotnek.com/Blog/Apps/apply-settings-to-keep-the-screen-active-for

link:https://dotnek.mystrikingly.com/

Related link:DOTNEK BLOG





:: برچسب‌ها: dotnek , seo , site ,
:: بازدید از این مطلب : 54
|
امتیاز مطلب : 0
|
تعداد امتیازدهندگان : 0
|
مجموع امتیاز : 0
تاریخ انتشار : دو شنبه 18 مرداد 1400 | نظرات ()
مطالب مرتبط با این پست
لیست
می توانید دیدگاه خود را بنویسید


نام
آدرس ایمیل
وب سایت/بلاگ
:) :( ;) :D
;)) :X :? :P
:* =(( :O };-
:B /:) =DD :S
-) :-(( :-| :-))
نظر خصوصی

 کد را وارد نمایید:

آپلود عکس دلخواه:








cache01last1628618496