Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.notify;
- import android.app.Activity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.EditText;
- public class MainActivity extends Activity implements OnClickListener
- {
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- findViewById(R.id.button_start).setOnClickListener(this);
- findViewById(R.id.button_stop).setOnClickListener(this);
- EditText importantNumber =(EditText)findViewById(R.id.edit_text);
- Intent notify = new Intent(new Intent(this, NotifyService.class));
- notify.putExtra("number", importantNumber + "" );
- }
- private void startService()
- {
- startService(new Intent(this, NotifyService.class));
- }
- private void stopService()
- {
- stopService(new Intent(this, NotifyService.class));
- }
- public void onClick(View v)
- {
- switch(v.getId())
- {
- case R.id.button_start:
- startService();
- break;
- case R.id.button_stop:
- stopService();
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment