This is a service class: public class serv extends Service { private static final String TAG = "MyService"; AlertDialog alertDialog @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } public void onCreate() { Toast.makeText(getApplicationContext(), "My Service Created",Toast.LENGTH_LONG).show(); } @Override public void onDestroy() { Toast.makeText(this, "My Service Stopped",Toast.LENGTH_LONG).show(); Log.d(TAG, "onDestroy"); //player.stop(); } @Override public void onStart(Intent intent, int startid) { Toast.makeText(this, "My Service Started",Toast.LENGTH_LONG).show(); Log.d(TAG, "onStart"); //player.start(); } } Call service from activity: public class MainActivity ...
A blog where you can find all codes for Android, Corona, Basic tutorials, Interview questions and more...