首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >实现ServiceConnection时的Android编译错误

实现ServiceConnection时的Android编译错误
EN

Stack Overflow用户
提问于 2013-08-10 12:12:09
回答 1查看 713关注 0票数 0

我正在努力添加应用程序中的计费,并在这份正式文件中工作。

我现在在Binding to IInAppBillingService

这是我的代码:

代码语言:javascript
复制
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方法。但我想我已经用这个例子所暗示的一种方式添加了它们。

我哪里出问题了?谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-10 12:19:12

此错误是因为您已按以下方式声明了类

public class CommunityActivity extends BaseActivity implements ServiceConnection

现在编译器希望您有这两个函数-- onServiceConnectedon ServiceDisconnected --用CommunityActivity实现。但在这门课上找不到他们。

删除此implements ServiceConnection,代码将成功编译。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18161738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档