Page 590 - 3-2
P. 590
Intent intent = new Intent(this,MyService.class);
stopService(intent);
}
}
● MyService
package org.androidtown.mdp_0608;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import java.io.PrintWriter;
import java.net.Socket;
public class MyService extends Service {
public MyService() {
}
Socket sock = null;
String data;
PrintWriter socket_out;
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException("Not yet implemented");
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
data = intent.getStringExtra("send");
if(data != null){
socket_out.println(data);
}
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onCreate() {
- 590 -