Last active
May 29, 2019 06:31
-
-
Save Shivamdhuria/934251186394ac061372b86cf7a2ddc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends AppCompatActivity { | |
private Button startServiceButton; | |
private Button stopServiceButton; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
startServiceButton = findViewById(R.id.start_button); | |
stopServiceButton = findViewById(R.id.stop_button); | |
startServiceButton.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
startService(new Intent(v.getContext(), ForegroundService.class)); | |
} | |
}); | |
stopServiceButton.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
stopService(new Intent(v.getContext(), ForegroundService.class)); | |
} | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment