我正在阅读Android绑定服务,http://developer.android.com/guide/components/bound-services.html
<div ng-controller="itemController">
<form ng-submit="addItem()">
<label>Name:</label><input type="text" name="name" value="" ng-model="newitem.name" placeholder="Item Name">
<label>Model No:</label><input type="text" name="model" value="" ng-model="newitem.model" placeholder="Model Number">
<label>Size:</label><input type="text" name="size" value="" ng-model="newitem.size" placeholder="Item Size">
<label>Colour:</label><input type="text" name="color" value="" ng-model="newitem.color" placeholder="Item Colour">
<br>
<label>Description:</label><textarea cols="30" rows="5" ng-model="newitem.description" placeholder="Description"></textarea>
<br>
<label>Photo:</label><input type="file" accept="imag/works" ngf-select="" ngf-multiple="true" class="form-control" id="img" name="img" placeholder="Image" ng-model="newitem.photo" multiple>
<br>
<button type="submit">Save</button>
</form>
<div ng-show="sendmessage">
Item Saved Successfully...........
</div>
<div>
}
所有教程,Android开发人员指南和书籍都建议将Binder作为内部服务类。真的必须只是内心阶级吗?
答案 0 :(得分:0)
它是一个内部类,因此您可以轻松返回外部Service
实例。你也可以把它变成一个外部类:
public class LocalBinder extends Binder {
private final LocalService mLocalService;
public LocalBinder(final LocalService service) {
mLocalService = service;
}
LocalService getService() {
return mLocalService;
}
}
使用内部类可以避免创建字段和构造函数的麻烦。