This question already has answers here:
Android, landscape only orientation?
(6 answers)
Closed 4 years ago.
Im trying to create a table in Android Studio with several fields, so the common Vertical mode for the activities doesn't seem useful to me.
I just want to change only one activity landscape mode to "Horizontal" and whenever i just change from this activity to another, go back to the regular "Vertical" mode.
I have tried searching on Google but all i found is just tutorials for changing the entire app to Vertical or Horizontal and i don't need that.
How can i do it?
Thanks
You can set this in your AndroidManifest.xml for each activity individually. For example:
<activity
android:name=".MyHorizontalActivity"
android:label="#string/my_horiz_activity"
android:screenOrientation="landscape" />
Related
I am Learning android development on my own, I am working on a quiz app, in this app, I want to add 100 questions (1 screen for 1 question)
user can go to the next question by swiping so how can I do it?
should I use 100 fragments for each question with the help of viewpager or any other method is available to do it?
You need to use ViewPage2 for swiping.
This question already has answers here:
How to prevent Screen Capture in Android
(16 answers)
Closed 4 years ago.
I have an Android banking app that prevents from taking a snapshot of the screen how do I do that in my own app.
Does anyone know how this is achieved?
It can be achieved by adding a simple code in the activity
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
}
Just add FLAG_SECURE flag in the activity. It Works for all Android versions higher than HONEYCOMB ie API 11 or higher.
Window flag: treat the content of the window as secure, preventing it from appearing in screenshots or from being viewed on non-secure displays.
Thsi prevents screenrecording and screenshots
This question already has answers here:
Set icon for Android application
(17 answers)
Closed 6 years ago.
I'm beginner at Android-programming/developing and I would like to change my own logo at my application.
I've found a folder, called 'mipmap'. I think, it could be this location where I can change it. Also I tried it without success.
Could somebody help me in this project?
Thanks a lot
Copy your image in the folder "mipmap"
Go to "manifests"
Here find the line :
android:icon="#mipmap/ic_launcher"
Change ic_launcher to your image name
android:icon="#mipmap/Your_icon_name"
This question already has answers here:
Keep the screen awake throughout my activity
(5 answers)
Closed 7 years ago.
Is there any way to force device not to sleep, if my app is shown on the screen? Does manifest.xml have a special attribute for this?
add this tag to your manifest file under activity tag
android:keepScreenOn="true"
Try this in your activity:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
or use tag in manifest
android:keepScreenOn="true"
Read
Android Documentation
This question already has answers here:
How to change an application icon programmatically in Android?
(11 answers)
Closed 2 years ago.
I know that same kind of question has been asked for activity icon, but my question is little bit different.
I just wanted to know whether we can set the application icon programmatically, I am not asking to change, I am just asking for setting it. I hope I am clear.
<application android:icon="drawable resource"> </application>
In the above example I am setting it in manifest file, but instead of manifest can I set it through java code.
As you can read here http://developer.android.com/guide/topics/manifest/manifest-intro.html the default's app icon is set in the manifest. As manifest is located in the app's /root it cannot be modified, so there's no way to do it.
You may consider that if you could change it while the app is running, changes wouldn't be saved in the manifest.