标记<action>属性名称包含无效字符'$'

时间:2015-08-13 10:55:59

标签: android android-manifest

Android Studio在定义像这样的服务时给出了错误(见标题):

<service
    android:name=".broadcast_receivers.SimpleWakefulReceiver$SimpleWakefulService"
    android:enabled="true" >
    <intent-filter>
        <action android:name=".broadcast_receivers.SimpleWakefulReceiver$SimpleWakefulService" />
    </intent-filter>
</service>

但是,Android Studio也会自动完成 - 建议使用此字符串作为name参数。

我已将SimpleWakefulService声明为公共静态类:

public class SimpleWakefulReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("onReceive " + intent.getAction());
        [...]
    }

    public static class SimpleWakefulService extends IntentService {
        public SimpleWakefulService() {
            super("[...]");
        }

        @Override
        protected void onHandleIntent(Intent intent) {
            [...]
        }
    }
}

我发现其他帖子声明在这种情况下'$'是正确的字符: Cannot start service in inner class - is it my Android Manifest? Declare Inner Activity In The Android Manifest

这是Android Studio的错误吗?

0 个答案:

没有答案