1. Are you ready for the Galaxy S20? Here is everything we know so far!

Help with newbie question..

Discussion in 'Android Development' started by jrojas537, Oct 21, 2014.

  1. jrojas537

    jrojas537 Lurker
    Thread Starter

    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
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - Help newbie question
  1. EvasiveEmanual
    Replies:
    4
    Views:
    408
  2. ChristineDorotheaRickner
    Replies:
    26
    Views:
    574
  3. FingleFangle
    Replies:
    1
    Views:
    501
  4. John9870
    Replies:
    6
    Views:
    351
  5. Gihansurendra
    Replies:
    3
    Views:
    296
  6. Scottv1982
    Replies:
    1
    Views:
    302
  7. tragicallyblazed
    Replies:
    4
    Views:
    449
  8. anna79
    Replies:
    1
    Views:
    339
  9. Michavz05
    Replies:
    9
    Views:
    538
  10. Rarena
    Replies:
    1
    Views:
    2,727

Share This Page

Loading...