电话呼叫后,小工具按钮无法正常工作

时间:2013-04-23 18:31:41

标签: android

我正在开发一个Android主页小部件。 当我通过单击按钮启动呼叫意图时(即在我通过单击小部件按钮开始的活动中), 通话结束后, 小部件的按钮不起作用。

当我点击按钮时,按钮的背景会发生变化, 因此小部件不会崩溃,它可以工作,但不会加载我认为的意图。并且没有关于此问题的日志记录。

我开始打这样的电话:

Intent callIntent=new Intent();
        callIntent.setAction(Intent.ACTION_CALL);

        callIntent.setData(Uri.parse("tel:"+phone));
        startActivity(callIntent);

然后完成活动。如果我没有再次完成活动它可以工作,但我需要完成活动。

编辑:

以下问题随机发生,电话有时屏幕变黑。当我按下主页按钮时它打开并且小部件按钮工作但是在4-5秒之后我按下动作,但有时屏幕不会变黑并且小部件按钮不起作用。

编辑:

LogCat填充了除最后一个之外的版本错误。但它已得到控制。我用这个控制版本: 如果(android.os.Build.VERSION.SDK_INT> = 11) 但它仍记录这些日志。但应用程序运行正常。

日志

    04-23 23:18:05.715: I/dalvikvm(4300): Could not find method android.appwidget.AppWidgetManager.notifyAppWidgetViewDataChanged, referenced from method org.MyApp.AWidget.AWidgetProvider.UpdateWidget
04-23 23:18:05.715: W/dalvikvm(4300): VFY: unable to resolve virtual method 123: Landroid/appwidget/AppWidgetManager;.notifyAppWidgetViewDataChanged ([II)V
04-23 23:18:05.715: D/dalvikvm(4300): VFY: replacing opcode 0x6e at 0x002a
04-23 23:18:05.723: I/dalvikvm(4300): Could not find method android.appwidget.AppWidgetManager.notifyAppWidgetViewDataChanged, referenced from method org.MyApp.AWidget.AWidgetProvider.onReceive
04-23 23:18:05.723: W/dalvikvm(4300): VFY: unable to resolve virtual method 123: Landroid/appwidget/AppWidgetManager;.notifyAppWidgetViewDataChanged ([II)V
04-23 23:18:05.723: D/dalvikvm(4300): VFY: replacing opcode 0x6e at 0x006e
04-23 23:18:05.727: I/dalvikvm(4300): Could not find method android.appwidget.AppWidgetManager.notifyAppWidgetViewDataChanged, referenced from method org.MyApp.AWidget.AWidgetProvider.onUpdate
04-23 23:18:05.727: W/dalvikvm(4300): VFY: unable to resolve virtual method 123: Landroid/appwidget/AppWidgetManager;.notifyAppWidgetViewDataChanged ([II)V
04-23 23:18:05.727: D/dalvikvm(4300): VFY: replacing opcode 0x6e at 0x0019
04-23 23:18:05.731: W/dalvikvm(4300): Unable to resolve superclass of Lorg/MyApp/AWidget/AWidgetService; (487)
04-23 23:18:05.731: W/dalvikvm(4300): Link of class 'Lorg/MyApp/AWidget/AWidgetService;' failed
04-23 23:18:05.731: E/dalvikvm(4300): Could not find class 'org.MyApp.AWidget.AWidgetService', referenced from method org.MyApp.AWidget.AWidgetProvider.onUpdate
04-23 23:18:05.731: W/dalvikvm(4300): VFY: unable to resolve const-class 612 (Lorg/MyApp/AWidget/AWidgetService;) in Lorg/MyApp/AWidget/AWidgetProvider;
04-23 23:18:05.731: D/dalvikvm(4300): VFY: replacing opcode 0x1c at 0x01ec
04-23 23:18:05.731: D/dalvikvm(4300): VFY: dead code 0x01ee-025e in Lorg/MyApp/AWidget/AWidgetProvider;.onUpdate (Landroid/content/Context;Landroid/appwidget/AppWidgetManager;[I)V
04-23 23:18:08.938: E/dalvikvm(4300): Could not find class 'android.widget.PopupMenu', referenced from method org.MyApp.AWidget.SetRemind.showPopupMenu
04-23 23:18:08.938: W/dalvikvm(4300): VFY: unable to resolve new-instance 482 (Landroid/widget/PopupMenu;) in Lorg/MyApp/AWidget/SetRemind;
04-23 23:18:08.938: D/dalvikvm(4300): VFY: replacing opcode 0x22 at 0x0000
04-23 23:18:08.941: D/dalvikvm(4300): VFY: dead code 0x0002-001d in Lorg/MyApp/AWidget/SetRemind;.showPopupMenu (Landroid/view/View;)V
04-23 23:18:09.184: D/dalvikvm(4300): GC_EXTERNAL_ALLOC freed 92K, 47% free 2874K/5379K, external 2003K/2108K, paused 172ms
04-23 23:18:09.238: D/dalvikvm(4300): GC_EXTERNAL_ALLOC freed 18K, 47% free 2867K/5379K, external 2591K/2934K, paused 22ms
04-23 23:18:09.293: D/dalvikvm(4300): GC_EXTERNAL_ALLOC freed 1K, 47% free 2869K/5379K, external 3134K/3613K, paused 26ms
04-23 23:18:09.469: D/dalvikvm(4300): GC_EXTERNAL_ALLOC freed 28K, 46% free 2932K/5379K, external 4281K/4292K, paused 23ms
04-23 23:18:10.754: D/dalvikvm(4300): GC_EXPLICIT freed 100K, 43% free 3394K/5895K, external 4445K/5380K, paused 26ms

我通过将方法移动到另一个类来清除所有版本的错误。但仍然相同,这次有更多的GC错误

最新日志:

04-24 00:41:03.345: D/dalvikvm(6003): GC_EXTERNAL_ALLOC freed 102K, 47% free 2878K/5379K, external 2003K/2108K, paused 31ms
04-24 00:41:03.396: D/dalvikvm(6003): GC_EXTERNAL_ALLOC freed 26K, 47% free 2862K/5379K, external 2591K/2934K, paused 26ms
04-24 00:41:03.450: D/dalvikvm(6003): GC_EXTERNAL_ALLOC freed 1K, 47% free 2865K/5379K, external 3134K/3613K, paused 21ms
04-24 00:41:03.708: D/dalvikvm(6003): GC_EXTERNAL_ALLOC freed 27K, 46% free 2930K/5379K, external 4281K/4292K, paused 61ms
04-24 00:41:05.341: D/dalvikvm(6003): GC_EXPLICIT freed 108K, 43% free 3397K/5895K, external 4445K/5380K, paused 29ms
04-24 00:41:32.685: D/dalvikvm(6316): GC_EXTERNAL_ALLOC freed 87K, 47% free 2866K/5379K, external 2003K/2108K, paused 25ms
04-24 00:41:32.735: D/dalvikvm(6316): GC_EXTERNAL_ALLOC freed 18K, 47% free 2858K/5379K, external 2591K/2934K, paused 21ms
04-24 00:41:32.774: D/dalvikvm(6316): GC_EXTERNAL_ALLOC freed 1K, 47% free 2861K/5379K, external 3134K/3613K, paused 19ms
04-24 00:41:33.024: D/dalvikvm(6316): GC_EXTERNAL_ALLOC freed 30K, 46% free 2927K/5379K, external 4281K/4292K, paused 31ms
04-24 00:41:34.103: D/dalvikvm(6316): GC_EXPLICIT freed 104K, 43% free 3393K/5895K, external 4445K/5380K, paused 24ms
04-24 00:41:35.071: D/dalvikvm(6316): GC_EXPLICIT freed 425K, 46% free 3406K/6279K, external 4068K/5081K, paused 25ms
04-24 00:41:35.923: D/dalvikvm(6316): GC_EXPLICIT freed 417K, 46% free 3413K/6279K, external 4068K/5081K, paused 27ms

1 个答案:

答案 0 :(得分:0)

以下为我工作

 Uri uri = Uri.fromParts("tel", phoneNumber, null);
 Intent callIntent = new Intent(Intent.ACTION_CALL, uri);
 callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 context.startActivity(callIntent);