2

以前にGCMでプロジェクトを実装しました。今すぐ新しいプロジェクトを作成したいのですが、新しいプロジェクト ID が必要で、それを取得しましたが、登録できません。プロジェクトIDについてですか?または以前のプロジェクト ID を使用できますか?

そして最後の質問:

<category android:name="my_app_package" />   

<permission android:name="my_app_package.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="my_app_package.permission.C2D_MESSAGE" />

アプリのパッケージ名とは? それはマニフェストファイルの先頭にありますか?それともGCM Javaページが含まれていますか?

4

5 に答える 5

2
<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.demo.demo"
    android:versionCode="1"
    android:versionName="1.0" >

    <!-- GCM requires Android SDK version 2.2 (API level 8) or above. -->
    <!-- The targetSdkVersion is optional, but it's always a good practice
         to target higher versions. -->
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="16"/>

    <!-- 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.ketan.demo.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <uses-permission
        android:name="com.ketan.demo.permission.C2D_MESSAGE" />

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

    <!-- Main activity. -->
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name="com.ketan.demo.DemoActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!--
          BroadcastReceiver that will receive intents from GCM
          services and handle them to the custom IntentService.

          The com.google.android.c2dm.permission.SEND permission is necessary
          so only GCM services can send data messages for the app.
        -->
        <receiver
            android:name="com.google.android.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.ketan.demo" />
            </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=".GCMIntentService" />
    </application>

</manifest>

GCM を実装したので、マニフェスト ファイルを参照してください。

于 2012-09-11T07:21:28.797 に答える
0

はい、以前の projectID を使用できますが、以前に登録していれば、通知を送信するときに projectID を使用する他のアプリケーションも通知を受け取ることができます。

新しいプロジェクト ID を使用できるはずです。間違っているかもしれませんので、もう一度確認してください。

2 番目の質問では、app_package がアプリケーションのメイン パッケージです。

于 2012-09-11T07:23:12.280 に答える
0

まず、GCM のこのリンクをたどる必要があります http://developer.android.com/guide/google/gcm/gs.html

すべてのプロジェクトには、GCM のパッケージ名とそのプロジェクト ID があります。プロジェクトのパッケージ名を指定しない場合は、以前のプロジェクト ID を通知に使用できます。

于 2012-09-11T07:24:41.793 に答える
0

まず、再登録する場合は、登録を解除する必要があります。

gcm サービスにはアプリ パッケージが必要です。GCMBroadcastReceiver を登録します。

<receiver
            android:name="com.google.android.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="my_app_package" />
            </intent-filter>
        </receiver>
于 2012-09-11T07:21:03.783 に答える
0

registration.one から応答が得られない場合、主な理由の 1 つは、マニフェスト ファイルが正しく構成されていないことです...特に、「package_name」(com.xxx.yyy などのアプリ パッケージ名) を正しく指定します。

于 2013-06-28T22:53:11.477 に答える