StatusBarNotification phonegap插件附加到phonegap项目

时间:2011-08-04 11:03:47

标签: cordova

我正在使用Phonegap,我正在寻找一些通知插件。我在GitHub上找到了https://github.com/phonegap/phonegap-plugins/tree/master/Android/StatusBarNotification插件,但我在NetBeans中遇到了编译问题。我做了说明所说的一切,但它不起作用。我有错误:

Creating output directories if needed...
Compiling aidl files into Java classes...
Compiling RenderScript files into Java classes and RenderScript bytecode...
Generating R.java / Manifest.java from the resources...
compile:
/home/procek/android-sdk-linux_x86/tools/ant/main_rules.xml:384: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
Compiling 2 source files to /home/procek/NetBeansProjects/myapp/bin/classes
/home/procek/NetBeansProjects/myapp/src/com/phonegap/statusBarNotification/StatusBarNotification.java:44: class StatusBarNotificationPlugin is public, should be declared in a file named StatusBarNotificationPlugin.java
public class StatusBarNotificationPlugin extends Plugin {
/home/procek/NetBeansProjects/myapp/src/com/phonegap/statusBarNotification/StatusBarNotification.java:91: package R does not exist
        int icon = R.drawable.notification;
                    ^
2 errors
/home/procek/android-sdk-linux_x86/tools/ant/main_rules.xml:384: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
你可以给我一些提示吗?在Android Manifest文件中,我有一些危险的行:

    <activity android:name="MainActivity"
              android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="StatusBarNotification"
              android:label="@string/app_name" android:configChanges="orientation|keyboardHidden">
        <intent-filter>
        </intent-filter>
    </activity>

有两个活动块...但没有这个我有同样的错误......

1 个答案:

答案 0 :(得分:1)

R.drawable.notification会在您的drawable文件夹中存在此图像吗?请检查。 我建议您使用此文件进行状态栏通知。在安装之前,请按照自述文件中的说明进行操作。 Plugin

创建一个图标img,并将其命名为icon.png。将它放在你的drawable文件夹/ drawable-hdpi / drawable-idpi中。现在,在创建通知时,您可以在systenotification.java中将其作为R.drawable.icon调用。确保你转到系统生成的java文件,它将是R.java并检查你是否有 public static final int icon = 0x7f020003

另一种方法是你可以在你的R.java中简单地创建 public static final int icon = 0x7f020002 并在你的systemnotification.java中调用它。这将绘制图像,无需物理创建图像。但我建议你去第一个选择。