从Android的源代码构建报警的应用程序错误 [英] Error in building Alarm app from android source
问题描述
我想建立一个应用程序,它扩展了基本的闹钟功能。因为我不是发明的报警功能的任何轮,我想使用Android默认报警它可公开。
不过,我已经尝试建立了很多次,但也有太多的错误(提<一个href="http://stackoverflow.com/questions/15595800/android-clock-source-git-clone-import-error">here也):
我想这方法还,但我仍然不能建立它。
任何人都可以请指导如何打造git的Android的树提供的Android应用程序。
链接我提到的:
-
<一个href="http://stackoverflow.com/questions/10118376/alarm-clock-$c$c-mcontext-variable-cant-be-resolved">Alarm时钟code:mContext变量不能得到解决
更新:
1)
Alarms.java:
行463:意向alarmChanged =新的意图(Intent.ACTION_ALARM_CHANGED);
错误:ACTION_ALARM_CHANGED不能得到解决或不是字段。
解决了这个错误,但与替换线(感谢@shayanpourvatan):
最后弦乐ACTION_ALARM_CHANGED =android.intent.action.ALARM_CHANGED;意图alarmChanged =新的意图(ACTION_ALARM_CHANGED);
2。)
AlarmKlaxon.java
89号线:mVibrator =新振动器();
错误:无法实例化型振动器
-----------------------------------
通过更换电源解决:
mVibrator =(震动)getSystemService(Context.VIBRATOR_SERVICE);
3。)
SetAlarm.java
行115:的FrameLayout含量=(的FrameLayout)getWindow()getDecorView()。
.findViewById(com.android.internal.R.id.content);
错误:com.android.internal.R不能被解析为一个变量
替换解决:
com.android.internal.R.id.content到android.R.id.content
解决了所有的错误,并能编译和运行在设备上。需要做的测试和检查去precations。这是我如何解决它们:
1)
Alarms.java:
行463:意向alarmChanged =新的意图(Intent.ACTION_ALARM_CHANGED);
错误:ACTION_ALARM_CHANGED不能得到解决或不是字段。
解决了这个错误,但与替换线(感谢@shayanpourvatan):
最后弦乐ACTION_ALARM_CHANGED =android.intent.action.ALARM_CHANGED;意图alarmChanged =新的意图(ACTION_ALARM_CHANGED);
2。)
AlarmKlaxon.java
89号线:mVibrator =新振动器();
错误:无法实例化型振动器
-----------------------------------
通过更换电源解决:
mVibrator =(震动)getSystemService(Context.VIBRATOR_SERVICE);
3。)
SetAlarm.java
行115:的FrameLayout含量=(的FrameLayout)getWindow()getDecorView()。
.findViewById(com.android.internal.R.id.content);
错误:com.android.internal.R不能被解析为一个变量
替换解决:
com.android.internal.R.id.content到android.R.id.content
而最后:
指定的孩子已经有父
如下所述的错误是固定的:
<一个href="http://stackoverflow.com/questions/15193389/the-specified-child-already-has-a-parent-in-google-alarmclock-$c$c">The指定的子已经在谷歌闹钟code 父
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.
Can anyone please guide on how to build the android application provided in git android tree.
Links I referred to:
Updates:
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.
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
-----------------------------------
Solved by replacing the line with:
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
Solved by replacing :
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.
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
-----------------------------------
Solved by replacing the line with:
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
Solved by replacing :
com.android.internal.R.id.content into android.R.id.content
And the lastly:
The specified child already has a parent
error is fixed as mentioned below:
The specified child already has a parent in google alarmclock code
这篇关于从Android的源代码构建报警的应用程序错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!