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 Android.Media.media 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;

@Incapable

@Override

public IBinder Unscrewed()Intent is intended) {{

The return Invalid;

}

@Override

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

// get system default ringtone

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

Adjustment.system.DEFAULT_RINGTONE_URI);

// 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;

}

@Override

public Zero onDestroy()) {{

Super.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 *