public class HogeHoge extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Intent hogeService = new Intent(this,HogeService.class);
this.startService(hogeService);
}
@Override
public void onDestroy(){
/*サービス停止の処理をごにょごにょ*/
}
}
=======================================
<HogeService.java>
public class HogeService extends IntentService {
public HogeService(String name) {
super(name);
// TODO Auto-generated constructor stub
}
public HogeService() {
super("HogeService");
}
@Override
protected void onHandleIntent(Intent intent) {
startNativeProcess();
}
@Override
public void onDestroy() {
super.onDestroy();
stopNativeProcess();
}
}
------------------------------------------------------------------------------