Can Widgets do this?

Bryan

Member
Licensed User
Longtime User
Just to introduce myself I am a programmer of a few different languages. I use Delphi Pascal, Visual Basic, Labview, Mikropascal for microcontrollers, Pic Basic for microcontrollers, and assembly.
I am an electronics technician also and like to interface hardware such as different sensors to computers.
I have an Android Galaxy Player 5. And have been considering writing some code for it.
My question is about Widgets. I kind of understand some things about them. I just need to know that if I write an application with Basic4Androids. Can a widget such as a button be used to run a specific sub in an application without actually visually running that application? Are widgets coded separate from any app you create or can their code be included in a created app. I am thinking that widgets and apps are two separate compiled pieces of code which are independant of each other. Or can an app and a widget be created all within the same code. I am having a problem with the concept of what widgets are, what they can do, and how they are used. Again can a widget such as a button or icon/image placed on your home screen of your device run a particular sub in an app without actually visually running that app.
Thanks, help is greatly appreciated.

Bryan
 

walterf25

Expert
Licensed User
Longtime User
Can widgets do this

Hi there, and welcome to basic4android, i also program in labview and visual studio, and am also a Technician, i work with µControllers and such.
anyhow about your question, if i understand correctly you want to create an app that will run in the background, for this you can create a service, a service will be executed and carry out what you program it to do at a certain time interval, A Widget will be another way to go, but i advice you to read more about servicves. You can find more information about them here.
if you don't mind can you elaborate a little more on what it is exactly that you're trying to do, if you have any additional questions you can pm me and i can try to help you.

Hope this helps a bit.
Cheers,
Walter
 
Upvote 0

Bryan

Member
Licensed User
Longtime User
I wanted to create a way to log date and time (very simple) to a text file from the home screen of a device. It would be easy to do from just a simple app. But I don't want to have to open an app to do it. So a widget button I thought would be the way to go. If I create an app that can log date and time to a text file at the push of a button can a widget communicate with that app to trigger the same event in that app without actually opening that app. Do it as a background task. Or maybe just have the widget code perform that the task of writing date and time to the same log file.
This is something I have been thinking about doing because I need to keep a record of when certain events occur. When they do I just hit a button on the home screen. I have to respond quickly and not need to open an app to do it. Making an app that will read and display the log file is needed as well as having the option to delete the log (text file). That I wouldn't have a problem doing. Just some how using a widget button on the home screen would be good. I basically just need to know if it is possible. I'm not looking for anyone to write code for me. I still have to purchase this programming software. I have looked at the trial and looks easy enough to write the app.
Just the widget part is alittle confusing.

Thanks,
Bryan
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
If you want to control When the data is save to the file, then go with a widget... In B4A they are codded just like a normal app, only the UI mechanism is diferent... some coding rules may also aply...
If you just want to automatize the data saving at known intervals, or even trigger the data saving either by a sistem event or some other, then a service is what you need... Services have NO UI...
 
Upvote 0
Top