我正在使用接收器每週創建一個警報箱。但是我得到以下錯誤下面令牌對於警報生成器中的應用程序不爲空
無法代碼添加窗口 - 令牌null不是一個應用程序
我使用的代碼是
public class AlarmReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
try {
displayAlert("Have you seen your chiropractor this month?", "Alert!", context);
}
catch (Exception e)
{
Toast.makeText(context, "There was an error somewhere, but we still received an alarm", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
public void displayAlert(final String error, String title, final Context context)
{
new AlertDialog.Builder(context.getApplicationContext()).setMessage(error)
.setTitle(title)
.setCancelable(true)
.setNeutralButton("Continue",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton){
dialog.cancel();
Intent newIntent = new Intent(context, Appointment.class);
context.startActivity(newIntent);
}
})
.show();
}
}
_但是,我得到下面的錯誤代碼_你得到什麼錯誤? –
@PradeepSimha的第一行檢查出來,無法添加窗口 –