0

GSMをAndroidアプリに統合しようとしています。ApiキーとSender_idを使用して、そのデモでGCM-Client-demoアプリと登録済みデバイスを実行できますが、アプリで同じコードを使用すると、デバイスをGCMに登録できません。

logcatでエラーが発生するのはです。

08-13 11:24:34.787: W/ActivityManager(2465): Unable to start service Intent { act=com.google.android.c2dm.intent.REGISTRATION cat=[com.demo.demogcm] cmp=com.demo.demogcm/.GCMIntentService (has extras) }: not found

私のマニフェストファイル。

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="15" />

<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />

<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!--
 Creates a custom permission so only this app can receive its messages.

 NOTE: the permission *must* be called PACKAGE.permission.C2D_MESSAGE,
       where PACKAGE is the application's package name.
-->
<permission
    android:name="com.demo.demogcm.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission
    android:name="com.demo.demogcm.permission.C2D_MESSAGE" />

<!-- This app has permission to register and receive data message. -->
<uses-permission
    android:name="com.google.android.c2dm.permission.RECEIVE" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".view.DemoActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     <receiver
        android:name="com.demo.demogcm.gcm.GCMBroadcastReceiver"
        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.demo.demogcm" />
        </intent-filter>
    </receiver>

    <!--
      Application-specific subclass of GCMBaseIntentService that will
      handle received messages.

      By default, it must be named .GCMIntentService, unless the
      application uses a custom BroadcastReceiver that redefines its name.
    -->
    <service android:name=".view.GCMIntentService" />
</application>

誰かが私がしている間違いを教えてもらえますか?

4

2 に答える 2

5

交換してください(メニフェストで)

android:name = "。view.GCMIntentService" コードとこの android:name = "。GCMIntentService" を使用し、GCMIntentServiceを同じパッケージ"com.demo.demogcm"に配置します

于 2012-08-13T06:13:35.470 に答える
4

このパッケージとクラス名を使用することもできます:<service android:name=".view.GCMIntentService" />ただし、追加の魔法が必要です

This intent service will be called by the GCMBroadcastReceiver (which is is provided by GCM library), as shown in the next step. It must be a subclass of com.google.android.gcm.GCMBaseIntentService, must contain a public constructor, and should be named my_app_package.GCMIntentService (unless you use a subclass of GCMBroadcastReceiver that overrides the method used to name the service).

これがどのように機能するか、ここで見ることができます。

于 2012-08-26T11:43:33.840 に答える