从android源构建警报应用程序时出错 [英] Error in building Alarm app from android source

查看:28
本文介绍了从android源构建警报应用程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个扩展基本闹钟功能的应用程序.由于我没有在闹钟功能中发明任何轮子,我想使用公开可用的 android 默认闹钟.

I want to build an app which extends basic alarm clock functionality. Since I am not inventing any wheel in the alarm functionality, I would like to use the android default alarm which is available openly.

然而,我已经尝试多次构建它,但错误太多(提到 此处也):

However I have tried to build it many times but there are just too many errors (mentioned here also):

我也尝试了这种方法,但我仍然无法构建它.

I tried this approach also but I am still not able to build it.

任何人都可以指导如何构建 git android tree 中提供的 android 应用程序.

Can anyone please guide on how to build the android application provided in git android tree.

我提到的链接:

  1. 闹钟代码:mContext 变量无法解析

来自 GIT 的闹钟 - 给出错误 - Android

更新:

1.)

    Alarms.java: 
    Line 463: Intent alarmChanged = new Intent(Intent.ACTION_ALARM_CHANGED);
    Error: ACTION_ALARM_CHANGED cannot be resolved or is not a field.

解决了这个错误,但用(感谢@shayanpourvatan)替换了该行:

Solved this error but replacing the line with (Thanks to @shayanpourvatan ):

final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; Intent alarmChanged = new Intent(ACTION_ALARM_CHANGED);

2.)

    AlarmKlaxon.java
    Line 89: mVibrator = new Vibrator();
    Error: Cannot instantiate the type Vibrator

    -----------------------------------

通过将行替换为:

mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

3.)

SetAlarm.java
    Line 115: FrameLayout content = (FrameLayout) getWindow().getDecorView()
                .findViewById(com.android.internal.R.id.content);
    Error:com.android.internal.R cannot be resolved to a variable

通过替换解决:

 com.android.internal.R.id.content into android.R.id.content

推荐答案

解决了所有错误并且能够在设备上编译和运行.需要进行测试并检查是否弃用.这是我解决它们的方法:

Solved all the error and was able to compile and run on device. Need to do testing and check for deprecations. Here is how I solved them:

1.)

Alarms.java: 
Line 463: Intent alarmChanged = new Intent(Intent.ACTION_ALARM_CHANGED);
Error: ACTION_ALARM_CHANGED cannot be resolved or is not a field.

解决了这个错误,但用(感谢@shayanpourvatan)替换了该行:

Solved this error but replacing the line with (Thanks to @shayanpourvatan ):

final String ACTION_ALARM_CHANGED = "android.intent.action.ALARM_CHANGED"; Intent alarmChanged = new Intent(ACTION_ALARM_CHANGED);

2.)

AlarmKlaxon.java
Line 89: mVibrator = new Vibrator();
Error: Cannot instantiate the type Vibrator

-----------------------------------

通过将行替换为:

mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);

3.)

SetAlarm.java
    Line 115: FrameLayout content = (FrameLayout) getWindow().getDecorView()
                .findViewById(com.android.internal.R.id.content);
    Error:com.android.internal.R cannot be resolved to a variable

通过替换解决:

com.android.internal.R.id.content into android.R.id.content

最后:

The specified child already has a parent

错误已修复,如下所述:

error is fixed as mentioned below:

指定的孩子已经有父母在谷歌闹钟代码中

这篇关于从android源构建警报应用程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆