Widgets基础篇(下)

文章翻译整理自:<wbr style="line-height:22px"><a target="_blank" rel="nofollow" href="http://developer.android.com/guide/topics/appwidgets/index.html" style="color:rgb(207,121,28); line-height:22px; text-decoration:none">http://developer.android.com/guide/topics/appwidgets/index.html</a></wbr><wbr style="line-height:25px"><div style="line-height:25px"><span style="line-height:25px"><span style="font-size:16px; line-height:28px">八,如何编写App Widget Configuration Activity</span></span></div> <div style="line-height:25px"> <span style="color:#003366; line-height:25px">如果你想让用户在添加一个新的App Widget时,能对该App Widget进行一些个性化的配置的话,你可以通过编写一个</span><span style="color:#ff9900; line-height:25px">App Widget Configuration Activity</span><span style="color:#003366; line-height:25px">来实现。在用户添加一个新的App Widget时,</span><span style="color:#ff9900; line-height:25px">configuration Activity能够自动被App Widget host启动</span><span style="color:#003366; line-height:25px">,</span> </div> <div style="line-height:25px"><span style="color:#003366; line-height:25px">在该Activity中,你可以让用户对App Widget进行一些个性化的设置,比如颜色,大小,更新频率以及其他的一些设置。</span></div> <div style="line-height:25px"> <span style="color:#003366; line-height:25px">configuration Activity应该像一般的Activity一样,在Android manifest文件中进行申明。App Widget host是通过</span><span style="line-height:16px; font-family:arial,sans-serif; font-size:13px"><code style="line-height:1em; color:rgb(0,0,255); font-family:monospace"><a rel="nofollow" href="http://developer.android.com/reference/android/appwidget/AppWidgetManager.html#ACTION_APPWIDGET_CONFIGURE" style="color:rgb(207,121,28); line-height:23px; text-decoration:none">ACTION_APPWIDGET_CONFIGURE</a></code><span style="color:#000080; line-height:23px"></span></span><span style="line-height:16px; font-family:arial,sans-serif; font-size:13px"><span style="color:#003366; line-height:23px">action 来启动configuration Activity</span></span><span style="line-height:16px; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px">,</span><span style="line-height:25px; color:rgb(0,51,102)">所以configuration Activity必须要能接收该Action.</span> </div> <div style="line-height:25px"> <span style="color:#003366; line-height:25px">比如,</span><span style="line-height:25px">示例4</span> </div> <div style="line-height:25px"> <span style="line-height:25px">示例4</span><span style="color:#003366; line-height:25px">:</span> </div> <div style="line-height:25px"> <span style="line-height:normal; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"></span> <pre style="line-height:inherit; color:rgb(0,112,0); font-family:monospace; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(204,204,204); border-right-color:rgb(204,204,204); border-bottom-color:rgb(204,204,204); border-left-color:rgb(204,204,204); background-color:rgb(250,250,250); padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px; margin-top:0px; margin-bottom:1em; margin-left:1em; overflow-x:auto; overflow-y:auto"><span style="line-height:23px; color:rgb(0,0,136)">&lt;activity</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(136,34,136)">android:name</span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,136,0)">".ExampleAppWidgetConfigure"</span><span style="line-height:23px; color:rgb(0,0,136)">&gt;</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(0,0,136)">&lt;intent-filter&gt;</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(0,0,136)">&lt;action</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(136,34,136)">android:name</span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,136,0)">"android.appwidget.action.APPWIDGET_CONFIGURE"</span><span style="line-height:23px; color:rgb(0,0,136)">/&gt;</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(0,0,136)">&lt;/intent-filter&gt;</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(0,0,136)">&lt;/activity&gt;</span></pre> </div> <div style="line-height:25px"> <span style="color:#003366; line-height:25px">同时在AppWidgetProviderInfo XML文件中,你也必须使用</span><span style="color:#ff9900; line-height:25px">android:configure</span><span style="color:#003366; line-height:25px">属性中指明:当用户在添加一个新的App Widget时,哪个Configuration Activity将被启动。具体可以参照</span><span style="line-height:25px">示例5</span> </div> <div style="line-height:25px"><span style="line-height:25px">示例5:</span></div> <div style="line-height:25px"> <span style="line-height:normal; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"></span> <pre style="line-height:inherit; color:rgb(0,112,0); font-family:monospace; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(204,204,204); border-right-color:rgb(204,204,204); border-bottom-color:rgb(204,204,204); border-left-color:rgb(204,204,204); background-color:rgb(250,250,250); padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px; margin-top:0px; margin-bottom:1em; margin-left:1em; overflow-x:auto; overflow-y:auto"><span style="line-height:23px; color:rgb(0,0,136)">&lt;appwidget-provider</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(136,34,136)">xmlns:android</span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,136,0)">"http://schemas.android.com/apk/res/android"</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"> ...<br style="line-height:23px"></span><span style="line-height:23px; color:rgb(136,34,136)">android:configure</span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,136,0)">"com.example.android.ExampleAppWidgetConfigure"</span><span style="line-height:23px; color:rgb(0,0,0)"> <br style="line-height:23px"> ... </span><span style="line-height:23px; color:rgb(0,0,136)">&gt;</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(0,0,136)">&lt;/appwidget-provider&gt;</span></pre> </div> <div style="line-height:25px"> <span style="line-height:25px">注意:</span><span style="color:#000080; line-height:25px">这里的Activity用的是完整的名字,因为它将在你的APK包外被引用。</span> </div> <div style="line-height:25px"><span style="color:#003366; line-height:25px">以上就是启动一个Configuration Activity,所有需要你做的。现在你需要关心的是Activity本身,在实现一个Configuration Activity时,你需要记住两件非常重要的事情。</span></div> <div style="line-height:25px"> <span style="color:#003366; line-height:25px"><span style="line-height:25px">首先</span>,</span><span style="color:#000080; line-height:25px">App Widget host调用configuration Activity,configuration Activity应该总是能返回一个执行结果。返回结果应该包含同过Intent传给configuration Activity的要添加的App Widget的ID(该ID通过<span style="line-height:13px; font-family:monospace; font-size:13px"><a rel="nofollow" href="http://developer.android.com/reference/android/appwidget/AppWidgetManager.html#EXTRA_APPWIDGET_ID" style="color:rgb(207,121,28); line-height:23px; text-decoration:none">EXTRA_APPWIDGET_ID</a></span>保存在Intent的extras中)</span> </div> <div style="line-height:25px"> <span style="line-height:25px"><span style="color:#003366; line-height:25px">其次</span></span><span style="color:#000080; line-height:25px">,如果我们App Widget的有configuration Activity,那么当App Widget被创建时,AppWidgetProvider的onUpdate()方法将不会被调用,(当configuration Activity被创建启动的时候,系统将不再发送</span><span style="color:#ff9900; line-height:25px">ACTION_APPWIDGET_UPDATE</span><span style="color:#000080; line-height:25px">广播)。当App Widget被创建的时候,configuration Activity必须负责请求AppWidgetManager对App Widget进行首次更新。然而以后只要更新时间到了,系统还是会发送</span><span style="color:#ff9900; line-height:25px">ACTION_APPWIDGET_UPDATE</span><span style="color:#000080; line-height:25px">广播,因此App Widget的</span><span style="color:#0000ff; line-height:25px">onUpdate()</span><span style="color:#000080; line-height:25px">方法还是会被调用,以进行App Widget更新。系统只是在App Widget被创建的时候,不发送ACTION_APPWIDGET_UPDATE广播。</span> </div> <div style="line-height:25px"><span style="color:#000080; line-height:25px">在后面的文章,我们将讲述如何在configuration Activity中返回执行结果和更新App Widget.</span></div> <div style="line-height:25px"><span style="line-height:25px">九、如何在configuration Activity中更新App Widget和返回结果</span></div> <div style="line-height:25px"> <span style="color:#003366; line-height:25px">configuration Activity必须负责请求AppWidgetManager对App Widget进行的首次更新。你可以通过</span><span style="line-height:16px; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"><code style="line-height:1em; color:rgb(0,112,0); font-family:monospace"><a rel="nofollow" href="http://developer.android.com/reference/android/appwidget/AppWidgetManager.html" style="color:rgb(0,102,153); line-height:23px; text-decoration:none">AppWidgetManager</a></code></span><span style="line-height:25px; color:rgb(0,51,102)">直接来更新App Widget.</span> </div> <div style="line-height:25px"> <span style="color:#003366; line-height:25px">以下是</span><span style="line-height:25px; color:rgb(0,0,128)">在configuration Activity中更新App Widget和退出</span><span style="line-height:25px; color:rgb(0,0,128)">configuration Activity的主要步骤:</span> </div> <div style="line-height:25px"> <span style="line-height:25px; color:rgb(0,0,128)"><span style="line-height:25px">第一、</span>在启动</span><span style="color:#000080; line-height:25px">configuration Activity的Intent中得到App Widget的ID。比如,</span><span style="line-height:25px">示例6</span><span style="color:#000080; line-height:25px">.</span> </div> <div style="line-height:25px"><span style="line-height:25px">示例6:</span></div> <div style="line-height:25px"> <span style="line-height:16px; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"></span> <pre style="line-height:inherit; color:rgb(0,112,0); font-family:monospace; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(204,204,204); border-right-color:rgb(204,204,204); border-bottom-color:rgb(204,204,204); border-left-color:rgb(204,204,204); background-color:rgb(250,250,250); padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px; margin-top:0.5em; margin-bottom:0px; margin-left:1em; overflow-x:auto; overflow-y:auto"><span style="line-height:23px; color:rgb(102,0,102)">Intent</span><span style="line-height:23px; color:rgb(0,0,0)"> intent </span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,0,0)"> getIntent</span><span style="line-height:23px; color:rgb(102,102,0)">();</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(102,0,102)">Bundle</span><span style="line-height:23px; color:rgb(0,0,0)"> extras </span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,0,0)"> intent</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">getExtras</span><span style="line-height:23px; color:rgb(102,102,0)">();</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(0,0,136)">if</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(0,0,0)">extras </span><span style="line-height:23px; color:rgb(102,102,0)">!=</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(0,0,136)">null</span><span style="line-height:23px; color:rgb(102,102,0)">)</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(102,102,0)">{</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"> mAppWidgetId </span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,0,0)"> extras</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">getInt</span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(102,0,102)">AppWidgetManager</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">EXTRA_APPWIDGET_ID</span><span style="line-height:23px; color:rgb(102,102,0)">,</span><span style="line-height:23px; color:rgb(0,0,0)"> <br style="line-height:23px"></span><span style="line-height:23px; color:rgb(102,0,102)">AppWidgetManager</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">INVALID_APPWIDGET_ID</span><span style="line-height:23px; color:rgb(102,102,0)">);</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px"></span><span style="line-height:23px; color:rgb(102,102,0)">}</span></pre> </div> <div style="line-height:25px"><span style="color:#000080; line-height:25px"><span style="line-height:25px">第二、</span>进行App Widget配置的处理。</span></div> <div style="line-height:25px"> <span style="color:#000080; line-height:25px"><span style="line-height:25px">第三、</span>当App Widget的配置事务被处理完后,调用来</span><span style="line-height:16px; color:rgb(0,112,0); font-family:monospace; font-size:13px; white-space:pre"><span style="line-height:23px; color:rgb(102,0,102)">AppWidgetManager</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">getInstance</span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(0,0,0)">context</span><span style="line-height:23px; color:rgb(102,102,0)">)</span></span><span style="line-height:25px; color:rgb(0,0,128)">得到AppWidgetManager的一个实例。</span> </div> <div style="line-height:25px"> <span style="color:#000080; line-height:25px">比如,</span><span style="line-height:25px">示例7</span><span style="color:#000080; line-height:25px">.</span> </div> <div style="line-height:25px"> <span style="line-height:25px">示例7</span><span style="color:#000080; line-height:25px">:</span> </div> <div style="line-height:25px"> <span style="line-height:16px; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"></span> <pre style="line-height:inherit; color:rgb(0,112,0); font-family:monospace; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(204,204,204); border-right-color:rgb(204,204,204); border-bottom-color:rgb(204,204,204); border-left-color:rgb(204,204,204); background-color:rgb(250,250,250); padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px; margin-top:0.5em; margin-bottom:0px; margin-left:1em; overflow-x:auto; overflow-y:auto"><span style="line-height:23px; color:rgb(102,0,102)">AppWidgetManager</span><span style="line-height:23px; color:rgb(0,0,0)"> appWidgetManager </span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(102,0,102)">AppWidgetManager</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">getInstance</span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(0,0,0)">context</span><span style="line-height:23px; color:rgb(102,102,0)">);</span></pre> </div> <div style="line-height:25px"> <span style="color:#000080; line-height:25px"><span style="line-height:25px">第四、</span>调用</span><span style="line-height:16px; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"><code style="line-height:1em; color:rgb(0,112,0); font-family:monospace"><a rel="nofollow" href="http://developer.android.com/reference/android/appwidget/AppWidgetManager.html#updateAppWidget(int,%20android.widget.RemoteViews)" style="color:rgb(0,102,153); line-height:23px; text-decoration:none">updateAppWidget(int, RemoteViews)</a></code>函数,</span><span style="line-height:16px; font-family:arial,sans-serif; font-size:13px"><span style="color:#000080; line-height:23px">通过RemoteViews对象来更新App Widget.比如,</span><span style="line-height:23px">示例8。</span></span> </div> <div style="line-height:25px"><span style="line-height:20px; font-family:arial,sans-serif; font-size:13px"><span style="line-height:23px">示例8:</span></span></div> <div style="line-height:25px"> <span style="line-height:16px; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"></span> <pre style="line-height:inherit; color:rgb(0,112,0); font-family:monospace; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(204,204,204); border-right-color:rgb(204,204,204); border-bottom-color:rgb(204,204,204); border-left-color:rgb(204,204,204); background-color:rgb(250,250,250); padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px; margin-top:0.5em; margin-bottom:0px; margin-left:1em; overflow-x:auto; overflow-y:auto"><span style="line-height:23px; color:rgb(102,0,102)">RemoteViews</span><span style="line-height:23px; color:rgb(0,0,0)"> views </span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(0,0,136)">new</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(102,0,102)">RemoteViews</span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(0,0,0)">context</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">getPackageName</span><span style="line-height:23px; color:rgb(102,102,0)">(),</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px">R</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">layout</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">example_appwidget</span><span style="line-height:23px; color:rgb(102,102,0)">);</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px">appWidgetManager</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">updateAppWidget</span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(0,0,0)">mAppWidgetId</span><span style="line-height:23px; color:rgb(102,102,0)">,</span><span style="line-height:23px; color:rgb(0,0,0)"> views</span><span style="line-height:23px; color:rgb(102,102,0)">);</span></pre> </div> <div style="line-height:25px"><span style="line-height:20px; font-family:arial,sans-serif; font-size:13px"><span style="color:#000080; line-height:23px">第五、把执行结果放在Intent,用Intent返回结果,并结束configuration Activity。比如,</span><span style="line-height:23px">示例9</span><span style="color:#000080; line-height:23px">。</span></span></div> <div style="line-height:25px"><span style="line-height:20px; font-family:arial,sans-serif; font-size:13px"><span style="line-height:20px">示例9:</span></span></div> <div style="line-height:25px"> <span style="line-height:16px; color:rgb(51,51,51); font-family:arial,sans-serif; font-size:13px"></span> <pre style="line-height:inherit; color:rgb(0,112,0); font-family:monospace; border-top-width:1px; border-right-width:1px; border-bottom-width:1px; border-left-width:1px; border-top-style:solid; border-right-style:solid; border-bottom-style:solid; border-left-style:solid; border-top-color:rgb(204,204,204); border-right-color:rgb(204,204,204); border-bottom-color:rgb(204,204,204); border-left-color:rgb(204,204,204); background-color:rgb(250,250,250); padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px; margin-top:0px; margin-bottom:1em; margin-left:1em; overflow-x:auto; overflow-y:auto"><span style="line-height:23px; color:rgb(102,0,102)">Intent</span><span style="line-height:23px; color:rgb(0,0,0)"> resultValue </span><span style="line-height:23px; color:rgb(102,102,0)">=</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(0,0,136)">new</span><span style="line-height:23px; color:rgb(0,0,0)"> </span><span style="line-height:23px; color:rgb(102,0,102)">Intent</span><span style="line-height:23px; color:rgb(102,102,0)">();</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px">resultValue</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">putExtra</span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(102,0,102)">AppWidgetManager</span><span style="line-height:23px; color:rgb(102,102,0)">.</span><span style="line-height:23px; color:rgb(0,0,0)">EXTRA_APPWIDGET_ID</span><span style="line-height:23px; color:rgb(102,102,0)">,</span><span style="line-height:23px; color:rgb(0,0,0)"> mAppWidgetId</span><span style="line-height:23px; color:rgb(102,102,0)">);</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px">setResult</span><span style="line-height:23px; color:rgb(102,102,0)">(</span><span style="line-height:23px; color:rgb(0,0,0)">RESULT_OK</span><span style="line-height:23px; color:rgb(102,102,0)">,</span><span style="line-height:23px; color:rgb(0,0,0)"> resultValue</span><span style="line-height:23px; color:rgb(102,102,0)">);</span><span style="line-height:23px; color:rgb(0,0,0)"><br style="line-height:23px">finish</span><span style="line-height:23px; color:rgb(102,102,0)">();</span></pre> </div> <div style="line-height:25px"> <span style="font-family:arial,sans-serif; font-size:13px; line-height:23px"><span style="line-height:20px"><span style="line-height:23px">注意</span>:<span style="color:#000080; line-height:23px">当</span></span></span><span style="color:#000080; line-height:25px">configuration Activity首次启动的时候,应该把Activity的返回结果设置为RESULT_CANCELED.</span> </div> <div style="line-height:25px"> <span style="color:#000080; line-height:25px">这样如果用户中途退出了configuration Activity的话,系统将通知App Widget host该configuration被取消,这样App Widget将不被添加</span>.</div> <div style="line-height:25px"> <span style="line-height:25px; font-family:Arial,Helvetica,simsun,u5b8bu4f53"><span style="color:#000080; line-height:22px">关于Configuration Activity的完整实例请参考</span></span><span style="line-height:25px; font-family:Arial,Helvetica,simsun,u5b8bu4f53"><span style="color:#000080; line-height:22px"><span style="line-height:16px; font-family:arial,sans-serif; font-size:13px">《</span></span></span><strong><a title="阅读全文" target="_blank" href="http://hubingforever.blog.163.com/blog/static/171040579201162835830396/" style="color:rgb(207,121,28); line-height:25px; text-decoration:none">Widgets基础篇附件3(ExampleAppWidgetConfigure.java)</a></strong><span style="line-height:25px; font-family:Arial,Helvetica,simsun,u5b8bu4f53"><span style="line-height:16px; color:rgb(0,0,128); font-family:arial,sans-serif; font-size:13px">》</span></span> </div> <div style="line-height:25px"></div> <div style="line-height:25px"></div> </wbr>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值