如何包含bump sdk但是禁用它

时间:2012-09-18 11:26:54

标签: android bump

使用android下载中提供的示例应用程序,我想在onCreate()方法中使用api.disableBumping()来添加broadcastreceiver,但禁用了bumping直到另行通知。应用程序一直在崩溃。

任何指针?

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.main);

    bindService(new Intent(IBumpAPI.class.getName()),
                connection, Context.BIND_AUTO_CREATE);

    IntentFilter filter = new IntentFilter();
    filter.addAction(BumpAPIIntents.CHANNEL_CONFIRMED);
    filter.addAction(BumpAPIIntents.DATA_RECEIVED);
    filter.addAction(BumpAPIIntents.NOT_MATCHED);
    filter.addAction(BumpAPIIntents.MATCHED);
    filter.addAction(BumpAPIIntents.CONNECTED);
    registerReceiver(receiver, filter);

    try {
        api.disableBumping();
    } catch (RemoteException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


}

调试信息

Thread [<1> main] (Suspended (exception RuntimeException))  
ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1816    
ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1837 
ActivityThread.access$1500(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 132   
ActivityThread$H.handleMessage(Message) line: 1033  
ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
Looper.loop() line: 143 
ActivityThread.main(String[]) line: 4196    
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
Method.invoke(Object, Object...) line: 507  
ZygoteInit$MethodAndArgsCaller.run() line: 839  
ZygoteInit.main(String[]) line: 597 
NativeStart.main(String[]) line: not available [native method]

1 个答案:

答案 0 :(得分:0)

在下面的行中,我正在解释Bump的逻辑是如何工作的,

致电

bindService(new Intent(IBumpAPI.class.getName()), connection, Context.BIND_AUTO_CREATE);   

调用onServiceConnected,然后调用

    api = IBumpAPI.Stub.asInterface(binder);

    try  { api.configure("YOUR_API_KEY", "Bump User"); }
    catch (RemoteException e)  { } 

然后你等到收到广播 CONNECTED ,从那时起,由你决定何时调用api.enableBumping()或api.disableBumping()

注意:如果在调用api.configure()时连接断开,将引发远程异常。