我正在努力添加应用程序中的计费,并在这份正式文件中工作。
我现在在Binding to IInAppBillingService区
这是我的代码:
public class CommunityActivity extends BaseActivity implements ServiceConnection
{
ArrayAdapter<ChatMessage> adapter;
Dialog dialog;
ArrayList<ChatMessage> chat = new ArrayList <ChatMessage>( );
IInAppBillingService mService;
ServiceConnection mServiceConn = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onServiceConnected(ComponentName name,
IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
FlurryAgent.onStartSession(this, "8CA5LTZ5M73EG8R35SXG");
setContentView(R.layout.community);
bindService(new
Intent("com.android.vending.billing.InAppBillingService.BIND"),
mServiceConn, Context.BIND_AUTO_CREATE);但是我看到编译错误,说明我必须实现onServiceConnected和onServiceDisconnected方法。但我想我已经用这个例子所暗示的一种方式添加了它们。
我哪里出问题了?谢谢!
发布于 2013-08-10 12:19:12
此错误是因为您已按以下方式声明了类
public class CommunityActivity extends BaseActivity implements ServiceConnection
现在编译器希望您有这两个函数-- onServiceConnected和on ServiceDisconnected --用CommunityActivity实现。但在这门课上找不到他们。
删除此implements ServiceConnection,代码将成功编译。
https://stackoverflow.com/questions/18161738
复制相似问题