View a Fullscreen image after onClick button
up vote
1
down vote
favorite
I'm developing my first app so I'm a newbie of Android programming.
I have a button that will turn off my screen with the command
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
but the command takes about 2 seconds to turn off de screen.
So I want that immediately after clicking on the button, before launching the screen-off command will be showed a fullscreen black image, to simulate the screen off. Maybe after launching the command, with a little delay of 5seconds I have to take the image away. How can I do?
android
add a comment |
up vote
1
down vote
favorite
I'm developing my first app so I'm a newbie of Android programming.
I have a button that will turn off my screen with the command
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
but the command takes about 2 seconds to turn off de screen.
So I want that immediately after clicking on the button, before launching the screen-off command will be showed a fullscreen black image, to simulate the screen off. Maybe after launching the command, with a little delay of 5seconds I have to take the image away. How can I do?
android
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm developing my first app so I'm a newbie of Android programming.
I have a button that will turn off my screen with the command
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
but the command takes about 2 seconds to turn off de screen.
So I want that immediately after clicking on the button, before launching the screen-off command will be showed a fullscreen black image, to simulate the screen off. Maybe after launching the command, with a little delay of 5seconds I have to take the image away. How can I do?
android
I'm developing my first app so I'm a newbie of Android programming.
I have a button that will turn off my screen with the command
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
but the command takes about 2 seconds to turn off de screen.
So I want that immediately after clicking on the button, before launching the screen-off command will be showed a fullscreen black image, to simulate the screen off. Maybe after launching the command, with a little delay of 5seconds I have to take the image away. How can I do?
android
android
asked Nov 10 at 23:52
Nico Weide Zangirolami
82
82
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Firstly, prepare an ImageView
in your layout xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/colorAccent" />
</android.support.constraint.ConstraintLayout>
notice set the initial visibility of ImageView
is gone.
Then in the OnClickListener
of button:
yourImageView.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
yourImageView.setVisibility(View.GONE);
}
}, 5000); //after 5 seconds
1. ImageView is now match_parent and it keeps Titlebar and system StatusBar Visible (also NavigationBar for who has one). 2. Some buttons and switches on layout keeps being on top
– Nico Weide Zangirolami
Nov 11 at 1:21
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Firstly, prepare an ImageView
in your layout xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/colorAccent" />
</android.support.constraint.ConstraintLayout>
notice set the initial visibility of ImageView
is gone.
Then in the OnClickListener
of button:
yourImageView.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
yourImageView.setVisibility(View.GONE);
}
}, 5000); //after 5 seconds
1. ImageView is now match_parent and it keeps Titlebar and system StatusBar Visible (also NavigationBar for who has one). 2. Some buttons and switches on layout keeps being on top
– Nico Weide Zangirolami
Nov 11 at 1:21
add a comment |
up vote
0
down vote
accepted
Firstly, prepare an ImageView
in your layout xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/colorAccent" />
</android.support.constraint.ConstraintLayout>
notice set the initial visibility of ImageView
is gone.
Then in the OnClickListener
of button:
yourImageView.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
yourImageView.setVisibility(View.GONE);
}
}, 5000); //after 5 seconds
1. ImageView is now match_parent and it keeps Titlebar and system StatusBar Visible (also NavigationBar for who has one). 2. Some buttons and switches on layout keeps being on top
– Nico Weide Zangirolami
Nov 11 at 1:21
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Firstly, prepare an ImageView
in your layout xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/colorAccent" />
</android.support.constraint.ConstraintLayout>
notice set the initial visibility of ImageView
is gone.
Then in the OnClickListener
of button:
yourImageView.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
yourImageView.setVisibility(View.GONE);
}
}, 5000); //after 5 seconds
Firstly, prepare an ImageView
in your layout xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
...
<ImageView
android:id="@+id/imageView"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@color/colorAccent" />
</android.support.constraint.ConstraintLayout>
notice set the initial visibility of ImageView
is gone.
Then in the OnClickListener
of button:
yourImageView.setVisibility(View.VISIBLE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Process su = Runtime.getRuntime().exec("su -c input keyevent 26");
yourImageView.setVisibility(View.GONE);
}
}, 5000); //after 5 seconds
answered Nov 11 at 0:11
navylover
2,82621117
2,82621117
1. ImageView is now match_parent and it keeps Titlebar and system StatusBar Visible (also NavigationBar for who has one). 2. Some buttons and switches on layout keeps being on top
– Nico Weide Zangirolami
Nov 11 at 1:21
add a comment |
1. ImageView is now match_parent and it keeps Titlebar and system StatusBar Visible (also NavigationBar for who has one). 2. Some buttons and switches on layout keeps being on top
– Nico Weide Zangirolami
Nov 11 at 1:21
1. ImageView is now match_parent and it keeps Titlebar and system StatusBar Visible (also NavigationBar for who has one). 2. Some buttons and switches on layout keeps being on top
– Nico Weide Zangirolami
Nov 11 at 1:21
1. ImageView is now match_parent and it keeps Titlebar and system StatusBar Visible (also NavigationBar for who has one). 2. Some buttons and switches on layout keeps being on top
– Nico Weide Zangirolami
Nov 11 at 1:21
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244570%2fview-a-fullscreen-image-after-onclick-button%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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