PendingIntent.getBroadcast无法解析

时间:2014-10-28 01:53:36

标签: android android-studio

我正在android studio 0.89中编写一个针对API级别20的小部件。在我的AppWidgetProvider中,我正在尝试创建一个待处理的意图来响应按下的按钮。我的问题是IDE没有识别PendingIntent中的任何方法。这是我的代码:

@Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widdlewidget_layout);

    Intent wifiIntent = new Intent(context, WiddleWidget.class);
    wifiIntent.setAction(WIFI_ACTION);

    ctx = context;

    PendingIntent pi = new PendingIntent.getBroadcast(context, 0 , wifiIntent, 0);

}

这个问题,就在我创建pi的路上。任何帮助表示赞赏。

干杯

1 个答案:

答案 0 :(得分:3)

小错误

只需从此处删除新关键字

PendingIntent pi = PendingIntent.getBroadcast(context, 0 , wifiIntent, 0);

说明:

您不能将关键字与 PendingIntent 一起使用,因为它是 singleton 类。 Singleton意味着这些类具有私有 构造函数