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
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