【发布时间】:2016-12-28 05:59:43
【问题描述】:
我有一个这样的界面:
public interface MyInterface {
public void aMethod();
}
我的自定义活动:
public class MyObject extends Activity {
private Context context;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
start(5,MyInterface handle);
}
public void start(final int duration, MyInterface handle){
Intent intent = new Intent(getApplicationContext(),myService.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Bundle bundle = new Bundle();
//Eroor !*** i can't pass handle.aMethod() to my service ***
bundle.putSerializable("handle",bundle.getSerializable(handle.aMethod()));
intent.putExtras(bundle);
startService(intent);
}
}
我有一个服务:
public class myService extends Service {
}
我想在我的服务中实现我的接口方法。我的活动将接口方法传递给服务并启动它。
我无法将 handle.aMethod() 传递给我的服务。
如何在活动方法中将接口传递给服务?
【问题讨论】:
-
为什么要将`接口传递给服务`?
-
好像要从服务调用接口方法??
-
@ρяσѕρєя K,我需要它!!
-
@Piyush Kukadiya 是的!我想在我的服务中实现接口方法
标签: android