Entering background mode [duplicate] - java

This question already has answers here:
Android - Simulate Home click
(4 answers)
Closed 1 year ago.
How to programmatically, e.g. using a button, make the app switch to background mode. Actually, I mean the action that the "home screen button" does, but I want to programmatically do it on my button. Thanks.
finish();
System.exit(0);
Cause exited from app.

you can use below backstack function to move the app to background mode:
moveTaskToBack(true)

Related

how to stop the screen rotation with out making changes to manifest [duplicate]

This question already has answers here:
Change orientation at runtime
(3 answers)
Closed 4 years ago.
I have been developing an audits app and want one of my screens not to rotate using the sensors. I don't want to change the manifest but want to do this by using java
any help would be appreciated.
To Make your application run only in portrait mode:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
To Make your application run only in landscape mode:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Note: Use it before setContentView method.
Use one of the following to restrict to specific orientation:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // for portrait
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // for landscape

How to use android button png as a button in my app [duplicate]

This question already has answers here:
How to set image button backgroundimage for different state?
(9 answers)
Closed 7 years ago.
I have a two png files. The button and it's "pressed state".
1)How do I replace the default android button with my png(the text of the button is included in the png, there's no need to define a textView over the image.
2) And also how do I implement the "onPress" state png???.
I've been 3 days searching for answers but there's little to no information on this subject in particular. I just found the rotate animations an all of that, but nothing on how to replace a default button with a drawable and then use another png file when the user press the button
If you want to use an image in your Button you just have to put it on the drawable folder and then in the background of your Button you can do:
android:background="#drawable/image"

Android - Not auto select an EditText field [duplicate]

This question already has answers here:
How to stop EditText from gaining focus when an activity starts in Android?
(54 answers)
Closed 7 years ago.
When I travel between Activities my app auto select the first EditText field on the screen, calling the keyboard.
There is any way to start an Activity without selecting anything by default?
You should add this to its parent layout
android:focusable="true" android:focusableInTouchMode="true"

How to put camera sensor inside my Activity? [duplicate]

This question already has an answer here:
Custom camera android
(1 answer)
Closed 8 years ago.
There is an application made by another developer and I need to continue it. It has an activity with a button that calls the default camera app as an intent with startActivityForResult. It works ok when they take only one picture per app session. But now the client wants to be able to take various photos from different position of the place and then upload them all to the web server. So I need another way to do that, faster than opening the camera app for every picture.
For this I wish to load the camera directly in my activity, place a 'shoot' button, a label with the number of pictures taken, an imageView with the last image saved, and a button to finish. As an example I show you this printed screen from Internet.
The idea is to save a picture on every button click, and save the file names in an array.
How can I use the camera this way and control it with a custom button?
I also try to control the camera and I am using this link
I hope it is useful for you. It has helped me to fix several bugs

Android Button Visiblity [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Problem with Image Button visibility! Android
When you start the application, the buttons should be visible for 5 seconds and then become invisible, so people will know there are buttons on the screen. For example If I have a MapActivity running, the button will be an obstruction. So I want to make it invisible. It should be visible again on touching that area or around that button area so as to trigger another activity. I tried setting visibilitiy. nextbutton.setVisibility(View.INVISIBLE) I can't make it visible onTouch() Please help me with the problem.
See your original thread which has more than enough information for you to do what you want.

Categories