1. <i id='zDUBe'><tr id='zDUBe'><dt id='zDUBe'><q id='zDUBe'><span id='zDUBe'><b id='zDUBe'><form id='zDUBe'><ins id='zDUBe'></ins><ul id='zDUBe'></ul><sub id='zDUBe'></sub></form><legend id='zDUBe'></legend><bdo id='zDUBe'><pre id='zDUBe'><center id='zDUBe'></center></pre></bdo></b><th id='zDUBe'></th></span></q></dt></tr></i><div id='zDUBe'><tfoot id='zDUBe'></tfoot><dl id='zDUBe'><fieldset id='zDUBe'></fieldset></dl></div>
          <bdo id='zDUBe'></bdo><ul id='zDUBe'></ul>

        <small id='zDUBe'></small><noframes id='zDUBe'>

        <legend id='zDUBe'><style id='zDUBe'><dir id='zDUBe'><q id='zDUBe'></q></dir></style></legend>

      2. <tfoot id='zDUBe'></tfoot>

        Android:从主屏幕小部件拨打电话

        时间:2023-09-08
          <i id='bNqNZ'><tr id='bNqNZ'><dt id='bNqNZ'><q id='bNqNZ'><span id='bNqNZ'><b id='bNqNZ'><form id='bNqNZ'><ins id='bNqNZ'></ins><ul id='bNqNZ'></ul><sub id='bNqNZ'></sub></form><legend id='bNqNZ'></legend><bdo id='bNqNZ'><pre id='bNqNZ'><center id='bNqNZ'></center></pre></bdo></b><th id='bNqNZ'></th></span></q></dt></tr></i><div id='bNqNZ'><tfoot id='bNqNZ'></tfoot><dl id='bNqNZ'><fieldset id='bNqNZ'></fieldset></dl></div>
            <legend id='bNqNZ'><style id='bNqNZ'><dir id='bNqNZ'><q id='bNqNZ'></q></dir></style></legend>

              <tbody id='bNqNZ'></tbody>
          • <small id='bNqNZ'></small><noframes id='bNqNZ'>

              <tfoot id='bNqNZ'></tfoot>

                  <bdo id='bNqNZ'></bdo><ul id='bNqNZ'></ul>
                  本文介绍了Android:从主屏幕小部件拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个小部件,我希望它在用户单击小部件时拨打特定号码的电话.我该怎么做呢?请帮忙.

                  I have a widget and I want it to make a phonecall to a particular number when the user clicks on the widget. How do i do this? Please help.

                  推荐答案

                  我能够使用以下代码让它工作:

                  I was able to get it working with this code:

                   @Override
                   public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
                      Log.d(LOG_TAG, "onUpdate(): ");
                      for (int appWidgetId : appWidgetIds) {
                  
                          Intent callIntent = new Intent(Intent.ACTION_CALL);
                          callIntent.setData(Uri.parse("tel:"+number));
                          PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, callIntent, 0);
                  
                          // Get the layout for the App Widget and attach an on-click listener to the button
                          RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.caller);
                          views.setOnClickPendingIntent(R.id.callButton, pendingIntent);
                  
                          // Tell the AppWidgetManager to perform an update on the current App Widget
                          appWidgetManager.updateAppWidget(appWidgetId, views);
                      }
                  }
                  

                  这篇关于Android:从主屏幕小部件拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 android Widgets 中实现 ListView 下一篇:如何从 Widget 传递数据并打开 Activity?[安卓]

                  相关文章

                    <i id='qewFV'><tr id='qewFV'><dt id='qewFV'><q id='qewFV'><span id='qewFV'><b id='qewFV'><form id='qewFV'><ins id='qewFV'></ins><ul id='qewFV'></ul><sub id='qewFV'></sub></form><legend id='qewFV'></legend><bdo id='qewFV'><pre id='qewFV'><center id='qewFV'></center></pre></bdo></b><th id='qewFV'></th></span></q></dt></tr></i><div id='qewFV'><tfoot id='qewFV'></tfoot><dl id='qewFV'><fieldset id='qewFV'></fieldset></dl></div>

                    <small id='qewFV'></small><noframes id='qewFV'>

                      • <bdo id='qewFV'></bdo><ul id='qewFV'></ul>
                      <legend id='qewFV'><style id='qewFV'><dir id='qewFV'><q id='qewFV'></q></dir></style></legend>

                      <tfoot id='qewFV'></tfoot>