我想构建一个扩展基本闹钟功能的应用程序。由于我没有发明警报功能的任何轮子,我想使用公开可用的Android默认警报。
但是我尝试多次构建它但是有太多错误(也提到了here):
我也试过这个approach,但我仍然无法构建它。
任何人都可以指导如何构建在git android树中提供的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):
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
答案 0 :(得分:4)
解决了所有错误,并能够在设备上编译和运行。需要进行测试并检查弃用。以下是我解决这些问题的方法:
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):
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
错误修复如下:
The specified child already has a parent in google alarmclock code