【问题标题】:how to include bump sdk but have it start disabled如何包含凹凸 sdk 但开始禁用它
【发布时间】:2012-09-10 15:54:47
【问题描述】:

使用 android 下载中提供的示例应用程序,我想在 onCreate() 方法中使用 api.disableBumping() 来添加广播接收器,但禁用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]

【问题讨论】:

  • 允许崩溃在 Eclipse 中继续,然后查看 LogCat 以获取引发原始异常的代码的实际堆栈跟踪。

标签: android bump


【解决方案1】:

在下面的几行中,我正在解释 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() 时连接断开,则会引发远程异常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-28
    • 2011-10-05
    • 2016-10-21
    • 2014-04-04
    • 1970-01-01
    • 2019-09-24
    • 1970-01-01
    相关资源
    最近更新 更多