Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.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 正在尝试将推送通知添加到我的应用_Android_Android Intent_Google Cloud Messaging - Fatal编程技术网

Android 正在尝试将推送通知添加到我的应用

Android 正在尝试将推送通知添加到我的应用,android,android-intent,google-cloud-messaging,Android,Android Intent,Google Cloud Messaging,我正在尝试向我的应用程序添加推送通知。。为此,我一直在关注Ravi Tamada的博客 顺便说一句,我能够用我的发件人id和注册id运行单个项目,所有推送通知都工作得很好。。当我尝试在我的应用程序中实现此功能时,就会出现问题。。运行项目时,在检查REGID=NULL后,应用程序停止运行 应用程序没有崩溃。。它只是停止,因为服务器没有响应,意图没有发生 我的错。。我有多个包裹。。服务具有正确的包名。。类别也是如此 那么应用程序有什么问题??为什么它不起作用 这是我的应用程序日志猫,包括推送通知

我正在尝试向我的应用程序添加推送通知。。为此,我一直在关注Ravi Tamada的博客

顺便说一句,我能够用我的发件人id和注册id运行单个项目,所有推送通知都工作得很好。。当我尝试在我的应用程序中实现此功能时,就会出现问题。。运行项目时,在检查REGID=NULL后,应用程序停止运行

应用程序没有崩溃。。它只是停止,因为服务器没有响应,意图没有发生


我的错。。我有多个包裹。。服务具有正确的包名。。类别也是如此

那么应用程序有什么问题??为什么它不起作用

这是我的应用程序日志猫,包括推送通知

  onReceive: com.google.android.c2dm.intent.REGISTRATION
  GCM IntentService class: com.example.smss.GCMIntentService
  V/GCMBaseIntentService(2959): Acquiring wakelock
这是我的舱单

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smss"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="18" />
<!-- GCM connects to Internet 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. -->
<permission
    android:name="com.example.smss.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.smss.permission.C2D_MESSAGE" />

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

<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />

<application
    android:allowBackup="true"
    android:icon="@drawable/logo"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.smss.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!-- Register Activity -->
    <activity
        android:name="com.quinoid.sms.pushnotifications.RegisterActivity"
        android:label="@string/app_name" >
    </activity>

    <!-- Main Activity -->
    <activity
        android:name="com.quinoid.sms.pushnotifications.InitialActivity"
        android:configChanges="orientation|keyboardHidden"
        android:label="@string/app_name" >
    </activity>

     <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.example.smss" />
        </intent-filter>
    </receiver>

    <service android:name="com.quinoid.sms.pushnotifications.GCMIntentService" />
</application>

您似乎没有正确实现gcminentservice类。在您的AndroidManifest.xml:

<service android:name="com.example.smss.GCMIntentService" />


并在正确的包名中创建相应的类。剩下的你可以按照教程来做。

您好,Android menifest文件中有太多的代码缺失,请查看下面的代码,并检查你的google play服务库和元数据

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ex_gcmdemo"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <permission android:name="com.example.ex_gcmdemo.permission.C2D_MESSAGE" android:protectionLevel="signature"></permission>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    <uses-permission  android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.example.ex_gcmdemo.permission.C2D_MESSAGE"/>


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.ex_gcmdemo.MainActivity"
            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="GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter >
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <category android:name="com.example.ex_gcmdemo"/>
            </intent-filter>
         </receiver>
        <service android:name="GcmIntentService"></service>

        <meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />
        <activity android:name="HomePage"></activity>
    </application>

</manifest>


我的坏。。我有多个包裹。。服务具有正确的包名。。类别也是如此。嗨。。这些是什么??上述所有内容没有改变吗?应用程序没有一步一步地集成gcm。如@SMR所述,您得到的错误是-
W/ActivityManager(395):无法启动服务意图{act=com.google.android.c2dm.Intent.REGISTRATION flg=0x10 pkg=com.example.smss cmp=com.example.smss/.gcminentservice(有额外服务)}U=0:not found
明确指出您的
GCMinentService
类不在
com.example.smss
中,该类可能重复
<service android:name="com.example.smss.GCMIntentService" />
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.ex_gcmdemo"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <permission android:name="com.example.ex_gcmdemo.permission.C2D_MESSAGE" android:protectionLevel="signature"></permission>

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.GET_ACCOUNTS"/>
    <uses-permission  android:name="android.permission.WAKE_LOCK"/>
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="com.example.ex_gcmdemo.permission.C2D_MESSAGE"/>


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.ex_gcmdemo.MainActivity"
            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="GcmBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter >
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <category android:name="com.example.ex_gcmdemo"/>
            </intent-filter>
         </receiver>
        <service android:name="GcmIntentService"></service>

        <meta-data android:name="com.google.android.gms.version"
           android:value="@integer/google_play_services_version" />
        <activity android:name="HomePage"></activity>
    </application>

</manifest>