• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help with newbie question..

jrojas537

Lurker
Oct 21, 2014
1
0
I am trying to setup my App to have one toggle switch and based on it's state return an SMS to a specific sender.

I have everything working except for the logic with the switch.

I am using a BoradcastReceiver to listen for the SMS and if it matches call on a Send() class that actually sends the SMS.

I would like to check the status of the togglebutton on the main activity within the Send() class in order to decide if to send the SMS or not.

How can I reference the switch from within the Send() class? I am getting errors every time I try to do it...

I can reference the Switch from within the MainActivity ... but not from the SMSend() instance.

here is the Send() class (called SMSend)

public class SMSend extends Activity
{
public void SEND_SMS(String sender) {

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(sender, null, "SENDING STUFF", null, null);

}

}

here is the Manifest portion for the Switch..

<Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/switch1"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:checked="true" />


How would I go about referencing the status of the switch from the SMSend() Class??

thank you.

-J
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones