【发布时间】:2019-07-15 02:00:05
【问题描述】:
在我的应用程序中,我希望 实现一些 interface 到 fragment!
当使用这个interface 时,我写这个是为了添加listeners,但是显示错误并且不允许我使用这个!
我将以下代码写入片段:
public class ServicesFragment extends Fragment implements IabHelper.OnIabSetupFinishedListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_services, container, false);
public class LoginCheckServiceConnection implements ServiceConnection {
public void onServiceConnected(ComponentName name, IBinder boundService) {
service = ILoginCheckService.Stub.asInterface((IBinder) boundService);
try {
boolean isLoggedIn = service.isLoggedIn();
if (isLoggedIn) {
iabHelper = new IabHelper(context, bazaarRSA);
iabHelper.startSetup(this);
} else {
if (Constants.isPackageInstalled(Constants.BAZAAR_PAYMENT_PACKAGE, packageManager)) {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setComponent(new ComponentName(Constants.BAZAAR_PAYMENT_PACKAGE, Constants.BAZAAR_LOGIN_ACTIVITY));
startActivity(intent);
} else {
Toast.makeText(context, "Not installed market on your device", Toast.LENGTH_SHORT).show();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void onServiceDisconnected(ComponentName name) {
service = null;
}
}
}
在此代码中:iabHelper.startSetup(this); 使用 this 时显示错误!
我该如何解决?
【问题讨论】:
标签: java android android-fragments interface