How to? SMS Widget

LisaM

Member
Licensed User
Longtime User
Hi guys,

just wondering if anyone can give me a basic run down of how to setup an SMS widget.

I have read through some threads and i am pretty sure i can fumble my way through setting up a basic sms messages received view/screen. but i am very unsure of how to send this info to a widget.

Basically i want to create a widget on my home screen that displays received sms messages sorted by most recent that is scrollable or gesture enable. e.g swipe up goes to next message, swipe down goes back to previous message
and tapping on the title bar opens the default sms application.

so do I put all the sms code in the main activity or do i set that up using remoteview in the widget service module?

Sorry this is my first time creating a widget so i am very new to it all.

any help would be appreciated, this is just a pet project of mine so no urgency in reply needed.

Cheers
Lisa
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You have two options to read the SMS messages. You can intercept new messages with an intent filter: Intent Filters - Intercepting SMS messages in the background

Or you can periodically retrieve the latest messages with SmsMessages object.

Widgets UI is much more limited than the UI of standard applications. There is no simple way to create a scrolling widget or to handle gestures. I recommend you to use two arrow buttons instead.

You should understand that your process will be killed from time to time and will be recreated as needed. This means that any information that you need must be saved in a file. You should read the data in Service_Create. See the quotes example. It will help you to get started.
 
Upvote 0

LisaM

Member
Licensed User
Longtime User
thnx
Was thinking of adding arrow buttons just to make it easier

I have managed to retreive all sms's from past 7 days and i can display the first on labels in my widget. What code do I need to put into the arrow buttons to go to the next record and back again?

Thnx again for your help
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…