Saturday , January 15 2022

Android Service Example for Background Processes – Android Coding by DMTechnolab

The package The trap.Simplified coding.androidserviceexample;

Import Android.App.Service;

Import Android.Content.Intent;

Import Player;

Import Android.The.IBinder;

Import Android.the provider.Adjustment;

Import Android.Support.Annotation.Incapable;

/ **

* Created by Belal on 12/30/2016.

* /

public class Myservice Is spread Service {{

// Creating an intermediate object

Private media Player The player;



public IBinder Unscrewed()Intent is intended) {{

The return Invalid;



public int onStartCommand()Intent is intended, int The flag, int Beginning) {{

// get system default ringtone

The player = media Player.To create()this,


// set loop play to true

// It will play the ringtone continuously

The player.Setloping()True);

// staring at the player

The player.Start());

// We have some options for service

// Start Sticky means start and stop service

The return START_STICKY;



public Zero onDestroy()) {{


// Player stopped when service is lost

The player.Stop());



Source link

About dmtechnolab

Check Also

Simplified Coding

Android Espresso Tutorial – Testing Fragment in Isolation – Android Coding by DMTechnolab

Welcome to another tutorial in the Android test series. And this post is called Android …

Leave a Reply

Your email address will not be published. Required fields are marked *