广播和接收额外的双打

广播和接收额外的双打

本文介绍了广播和接收额外的双打的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图广播演员在AM广播亚行的shell。在我的android BroadcastReceiver的,我订阅了广播和拉群众演员了捆绑的。

我的麻烦在于双打。我以为,一个广播可以包括双,因为捆绑类有一个 getDouble 的方法,如:

 双percentComplete = bundle.getDouble(PERCENT_COMPLETE);
 

不过,亚行壳AM广播命令似乎不支持双打,只是浮在水上。当我送了浮点数,Bundle.getDouble()方法抛出一个内部异常,记录在警戒水位,这表明它不能施放浮动翻番。

我可以发送双打,还是我被迫使用花车?

下面是标志specifiying我所知道的演员,所报告的上午。

 <意图>规范包括这些标志和参数:
    [-a<作用>] [-d< D​​ATA_URI>] [-t< MIME_TYPE>]
    [-C<类别> [-C<类别>] ...]
    [-e | --es< EXTRA_KEY> < EXTRA_STRING_VALUE> ...]
    [--esn< EXTRA_KEY> ...]
    [--ez< EXTRA_KEY> < EXTRA_BOOLEAN_VALUE> ...]
    [--ei< EXTRA_KEY> < EXTRA_INT_VALUE> ...]
    [--EL< EXTRA_KEY> < EXTRA_LONG_VALUE> ...]
    [--ef< EXTRA_KEY> < EXTRA_FLOAT_VALUE> ...]
    [--eu< EXTRA_KEY> < EXTRA_URI_VALUE> ...]
    [--ecn< EXTRA_KEY> < EXTRA_COMPONENT_NAME_VALUE>]
    [--eia< EXTRA_KEY> < EXTRA_INT_VALUE>,< EXTRA_INT_VALUE ...]
    [--ela< EXTRA_KEY> < EXTRA_LONG_VALUE>,< EXTRA_LONG_VALUE ...]
    [--efa< EXTRA_KEY> < EXTRA_FLOAT_VALUE>,< EXTRA_FLOAT_VALUE ...]
    [-n<成分>] [-f<旗帜与GT]
    [--grant阅读-URI的权限] [--grant写-URI的权限]
    [--debug-登录分辨率] [--exclude-停包]
    [--include-停包]
    [--activity-带来到前] [--activity清晰顶]
    [--activity清晰,当任务复位] [--activity  - 排除从 - 最近通话]
    [--activity推出 - 从史] [--activity,多任务]
    [--activity-NO-动画] [--activity-没有历史]
    [--activity-没有用户动作] [--activity- previous-是顶]
    [--activity-重排至前] [--activity-重置任务,如果需要的]
    [--activity单顶] [--activity-明确任务]
    [--activity任务上家]
    [--receiver注册,只有] [--receiver更换的申请中]
    [--selector]
    并[d URI> | <包装> | <成分&GT]
 

解决方案

您可以在亚行外壳中使用 URI 格式的:

 正在播出的意图:#Intent,行动= android.intent.action.YOUR_ACTION; d.percent_complete = 99.999;终点
 

请注意,与此格式,您必须首先启动亚行外​​壳,进入前点〜命令。

I'm attempting to broadcast extras in an am broadcast in adb shell. In my BroadcastReceiver in android, I'm subscribed to the broadcast and pull the extras out of the Bundle.

My trouble lies with doubles. I assumed that a broadcast could include a double since the Bundle class has a getDouble method, e.g.:

double percentComplete = bundle.getDouble("percent_complete");

However, the am broadcast command in adb shell doesn't seem to support doubles, only floats. When I send the float, the Bundle.getDouble() method throws an internal exception, logged at the warning level, indicating that it fails to cast Float to Double.

Can I send doubles, or am I forced to use floats?

Here are the flags for specifiying extras that I am aware of, as reported by am.

<INTENT> specifications include these flags and arguments:
    [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
    [-c <CATEGORY> [-c <CATEGORY>] ...]
    [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
    [--esn <EXTRA_KEY> ...]
    [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
    [--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
    [--el <EXTRA_KEY> <EXTRA_LONG_VALUE> ...]
    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]
    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]
    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]
    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]
    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]
    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]
    [-n <COMPONENT>] [-f <FLAGS>]
    [--grant-read-uri-permission] [--grant-write-uri-permission]
    [--debug-log-resolution] [--exclude-stopped-packages]
    [--include-stopped-packages]
    [--activity-brought-to-front] [--activity-clear-top]
    [--activity-clear-when-task-reset] [--activity-exclude-from-recents]
    [--activity-launched-from-history] [--activity-multiple-task]
    [--activity-no-animation] [--activity-no-history]
    [--activity-no-user-action] [--activity-previous-is-top]
    [--activity-reorder-to-front] [--activity-reset-task-if-needed]
    [--activity-single-top] [--activity-clear-task]
    [--activity-task-on-home]
    [--receiver-registered-only] [--receiver-replace-pending]
    [--selector]
    [<URI> | <PACKAGE> | <COMPONENT>]
解决方案

You can use URI format from within the adb shell:

am broadcast "intent:#Intent;action=android.intent.action.YOUR_ACTION;d.percent_complete=99.999;end"

Note that with this format, you have to start the adb shell first, before entering the am... command.

这篇关于广播和接收额外的双打的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 08:17