Android - how to know if user click on Home Screen - android

Is there a way to know if some user is clicked on the Home Screen of Android device. Something like homeScreen.onclicklistener
I tried to create a widgets and to listen for clicks, but this is not possible task, because there is no way to create widgets programmatically(auto adding), or maybe I don't know how to do it. I know this way is wrong but I had to tried.
Thanks in advance.
Screenshot from the Home Screen.

Related

How to build a random button picker with the blocks in app inventor 2?

I am a beginner and I don’t have any experience with coding etc. and I need help
The first screenshot:
shows my screen, and as you can depict from it there are two buttons- the first one is called RIGHT BUTTON, and the other one is called WRONG BUTTON. This is because clicking on the RIGHT BUTTON will open a next screen, whereas clicking on the WRONG BUTTON will result in going back to the previous screen. I thought that this is kind of boring :D that’s why I want to build something with the blocks that would choose randomly one of those buttons to be right and the other one to be wrong after the screen has initialized. To make it more clear. Every time I start the app I don’t know which button out of those two will take me one screen further- it could be the first or the second button- I want this to be a random pick.
Now, I have tried to build something like this blocks:
but I can’t find a suitable block, as you can see in screen shot 2 :D I assume, that this isn’t the way it should look like, but my skill is too low at the moment. I also assume that I will need an "if,then" block" I would be really grateful if someone built it and made a screenshot and post it here ;)
Basically, I am kindly asking for help. I have been looking on the internet for a tutorial etc. but I couldn’t find something that would really help me.
Thank you very much in advance ;)
When the button is pressed, instead of opening the next/prev screen, instead call a custom procedure and have that procedure decide if it was the right button to press or not. This can be done several ways, for instance with the Math.randomInteger block. You don't actually have to decide if it was the right button or not before the button is pressed, just do a "coin flip" at the time of the button press to decide (at least that's what it sounds like you wanted from your description).
Also note that the number of screens in AI is highly limited, and instead of going to another screen, you can just reuse the same buttons over and over (and maybe just show a label in the corner counting how far you've come), or make lots of buttons and only have the first two visible at the start, then as you progress hide/unhide the correct buttons.
Here this is the answer I have found for my problem using your info

Simple Button on Android Lock Screen with PIN

I am new in this forum and checked different threads here but did not found something similar to what I want to do...
Some Apps like MP3-Players or e.g. Spotify-App add some buttons when the lock screen is active (android nativ lock screen with PIN). In this case the displayed Date will dissapear to give more place to these "new" controls.
I have tried this without succes with a simple widget app by including android:widgetCategory="keyguard|home_screen" in the appwidget-provider xml information. The app widget is correctly operating on home screen but I see no widget when my screen locks.
So I think this uses other mechanism, may be an activity that hides the date and display controls on the lock screen.
Did anyone try something like this and can give me some tipp?
Thank you in advance!
Notes:
I dont want to implement a lock screen app, I would like to display a button and text on my lock screen like some common and existent apps do.
Used Android Version >= 4.2.2

Android menu chosing by pressing

I'm looking to do something on Android.
I want to press with my finger some image for like a second and make it appear a menu; however, I would still have to be pressing the screen while I move to the chosen option. From the moment I quit my finger from that option it would be the selected.
I've been looking for tutorial's and "how to"s but I can't have a clue on how to do that. I would appreciate some help in this topic
Thank you very much for your time
Its better to display the Context_Menu onLongClickListener and let the user to chose the option.
The idea of keeping the screen pressed its not really a good idea.
Most of the people are unaware of that. Whereas, if u just simply display a context menu and let user click the desired option, it will be better.

Custom view like lock/unlock screen of android

I would like to create effects like lock/unlock screen of android. I have attached the screenshot here as well. In lock screen we have 2 buttons but in my case I am having 3 buttons and the middle button must be draggable.
The middle button can be drag to left/right.
I know I have to create custom view for this to work but I don't have any idea about how to drag button left/right with nice effect(animations) which normally any android phone have.
I need guidance on this, so can anyone suggest me how to approach for this.
Basically i wish to move/slide button left and right and based on that want to take some action.
I have tried making a lockscreen application myself and i almost made it, but here are the facts you will have to face at the end
You will not be able to disable home or menu button.
you will need user permission (not the one you get while installing the application, the menu pops up every time you press the home button unless the user decides to make your application default home screen, if that does happen you have successfully made a lock screen) if you decide to make a home screen application too.
the lock screen doesn't go very well with passwords
But if it helps, here's what i did:
You need to create a service that keeps a check on the screen being off and on.
if the screen is off, you do nothing. when the screen if ON you start the activity and wait for the user to do the thing you want the user to make him unlock the screen. and when he does that you finish() the activity.
While doing that you need to setup a method that can listen to check the incoming calls you can do that by extending PhoneStateListener and also disable the back button.
Good Luck and if you are able to make any further progress do let me know.
Maybe this project could help you GlowPadView. I've used it succesfully in one project. Hope it's what you're looking for.

maintaining view state android

Please don't delete it because its a duplicate. I am an android developer with little experience. I have an app with 2 screens. The first has a bunch of options in a TableLayout each selected using a RadioButton.
What I want to do is, when I select one option and click a Button which appears below, the View should switch to the next screen showing some related data and when a Button is clicked I want it to come back to the same screen but then the rest of the options should be available to me so as to repeat the same process with another one of the options selected.
In short I want to be able to maintain the state of the first screen. I can't seem to be able to decide between using ViewSwitcher, ViewFlipper, or multiple Activities or using a single Activity which is what I am doing right now. But as my app gets bigger its very difficult to handle it. Please suggest the best way to do this. I am confused and desperately in need of help because my job depends on it. Thanks in advance
Use 2 activities. Launch the 2nd activity when the user clicks the button. When the user clicks the "back" button (or some other button you offer him) the 2nd activity finishes and the first activity (which was underneath it) is shown.
Note: You've not given us much information, so I can't guarantee that this is the best solution. From what you've said this is the solution I would recommend though. As they say in advertising "Your mileage may vary" ;-)

Categories

Resources