Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. package com.notify;
  2.  
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.view.View.OnClickListener;
  8. import android.widget.EditText;
  9.  
  10. public class MainActivity extends Activity implements OnClickListener
  11. {
  12.     @Override
  13.     public void onCreate(Bundle savedInstanceState)
  14.     {
  15.         super.onCreate(savedInstanceState);
  16.         setContentView(R.layout.main);
  17.        
  18.         findViewById(R.id.button_start).setOnClickListener(this);
  19.         findViewById(R.id.button_stop).setOnClickListener(this);
  20.        
  21.         EditText importantNumber =(EditText)findViewById(R.id.edit_text);
  22.        
  23.         Intent notify = new Intent(new Intent(this, NotifyService.class));
  24.        
  25.         notify.putExtra("number", importantNumber + ""  );
  26.     }
  27.    
  28.     private void startService()
  29.     {
  30.         startService(new Intent(this, NotifyService.class));
  31.     }
  32.    
  33.     private void stopService()
  34.     {
  35.         stopService(new Intent(this, NotifyService.class));
  36.     }
  37.  
  38.     public void onClick(View v)
  39.     {
  40.         switch(v.getId())
  41.         {
  42.         case R.id.button_start:
  43.             startService();
  44.             break;
  45.         case R.id.button_stop:
  46.             stopService();
  47.             break;
  48.         }
  49.     }
  50. }
Add Comment
Please, Sign In to add comment