Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android GCMService包名称表示法_Android_Google Cloud Messaging - Fatal编程技术网

Android GCMService包名称表示法

Android GCMService包名称表示法,android,google-cloud-messaging,Android,Google Cloud Messaging,我已经开始在我的应用程序中集成GCM。我对需要放置gcminentservice的包名没有什么疑问。正如android.developer站点所述 By default, it must be named .GCMIntentService, unless the application uses a custom BroadcastReceiver that redefines its name. 我的应用程序之前使用的是服务类,名为BackgroundService,它位于com.abc.

我已经开始在我的应用程序中集成GCM。我对需要放置gcminentservice的包名没有什么疑问。正如android.developer站点所述

By default, it must be named .GCMIntentService, unless the
application uses a custom BroadcastReceiver that redefines its name.
我的应用程序之前使用的是服务类,名为
BackgroundService
,它位于
com.abc.xyz.Service
包中。我的根包名是
com.abc.xyz.ui.activity
。我已经经历了,解决方案使用了那个些包名,但我的包名不一样。因为我的根包是不同的

我的查询是我需要重命名我的包结构还是有其他方法?我不想重命名包名,因为它是我们从一开始就使用的标准格式。那么还有其他方法可以做到这一点吗。提前谢谢

编辑

<receiver
            android:name="com.abc.xyz.service.GCMReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <!-- Receives the actual messages. -->
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <!-- Receives the registration id. -->
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.abc.xyz.ui.activity" />
            </intent-filter>
        </receiver>

        <service android:name="com.abc.xyz.service.BackgroundService" />


这帮助我得到了答案。所有的东西都包括在我的清单里。因此,我接受Anup的回答,因为它至少没有错。

只要您在服务的清单文件声明中对其进行了适当的限定,它就真的不重要了。你可以把它放在你想要的任何软件包中,只要确保你在使用它的任何地方都能正确地使用它。

我添加了小代码细节
这一行将是根软件包或直到我的服务软件包的地址。你能告诉我吗?它应该指向你正在注册广播接收器的活动的软件包。如果该活动位于
com.abc.xyz.ui.activity
中,则它应该指向该活动。我正在将其注册为MyApplication,它扩展了应用程序。那么应该给出MyApplication类的包名吗?此类位于包名
com.abc.xzy
下。如果您使用GCM示例应用程序中提供的库,则必须将此意向服务类放入父包中。例如:
com.pckg.name
是父文件夹,然后将服务类移动到该包中。Thnx pankaj,我的查询仅限于此。因为我的根包名是
com.abc.xyz.ui.activity
,但服务类在
com.abc.xyz.service
中。因此,除了重命名我的根包名称之外,还有其他选择吗?我认为如果根包是
com.abc.xyz.ui.activity
,那么
com.abc.xyz.service
将无法工作。(我不确定,但是)正如我所说,您应该重命名服务类的包结构
com.abc.xyz.ui.activity.service
(对于您的服务来说,这不是一个好的包结构)。