从Android的源代码构建报警的应用程序错误 [英] Error in building Alarm app from android source

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

问题描述

我想建立一个应用程序,它扩展了基本的闹钟功能。因为我不是发明的报警功能的任何轮,我想使用Android默认报警它可公开。

不过,我已经尝试建立了很多次,但也有太多的错误(提<一个href="http://stackoverflow.com/questions/15595800/android-clock-source-git-clone-import-error">here也):

我想这方法还,但我仍然不能建立它。

任何人都可以请指导如何打造git的Andr​​oid的树提供的Andr​​oid应用程序。

链接我提到的:

  1. <一个href="http://stackoverflow.com/questions/10118376/alarm-clock-$c$c-mcontext-variable-cant-be-resolved">Alarm时钟code:mContext变量不能得到解决

  2. 闹钟从GIT - 给出错误 - 安卓

更新:

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:

  1. Alarm clock code: mContext variable cant be resolved

  2. Alarm Clock from GIT - Gives error - Android

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屋!

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