SecurityException异常:不允许启动服务意向的行为= com.google.android.c2dm.intent.REGISTER [英] SecurityException: Not allowed to start service Intent act=com.google.android.c2dm.intent.REGISTER

查看:2010
本文介绍了SecurityException异常:不允许启动服务意向的行为= com.google.android.c2dm.intent.REGISTER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的错误 SecurityException异常:不允许启动服务意向,但看起来没有寻找许多主题后,很好地解决。

I get the error SecurityException: Not allowed to start service Intent but looks like it do not have good solution after searching many topics.

请帮帮我,

谢谢

P / S:

我要确保我用正确的 SENDER_ID 作为项目数量被定义为谷歌API控制台和纠正包的名称

I'm make sure I used correct SENDER_ID as project number was defined at Google API Console and correct package name.

错误:

Caused by: java.lang.SecurityException: Not allowed to start service Intent { act=com.google.android.c2dm.intent.REGISTER pkg=com.google.android.gms (has extras) } without permission com.google.android.c2dm.permission.RECEIVE
            at android.app.ContextImpl.startServiceAsUser(ContextImpl.java:1785)
            at android.app.ContextImpl.startService(ContextImpl.java:1757)
            at android.content.ContextWrapper.startService(ContextWrapper.java:480)
            at com.google.android.gms.gcm.GoogleCloudMessaging.e(Unknown Source)
            at com.google.android.gms.gcm.GoogleCloudMessaging.register(Unknown Source)
            at controller.RegisterGCMClientAsync.doInBackground(RegisterGCMClientAsync.java:62)
            at controller.RegisterGCMClientAsync.doInBackground(RegisterGCMClientAsync.java:18)
            at android.os.AsyncTask$2.call(AsyncTask.java:287)
            at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at java.lang.Thread.run(Thread.java:841)

Manifest.xml文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="app.cloudstringers" >

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="app.cloudstringers.Cloudstringers"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name="ui.fragment.RegisterWithAccountsFragment" />

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

    <permission
        android:name="app.cloudstringers.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <!-- Receiver GCM -->
    <receiver
        android:name="app.cloudstringers.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="app.cloudstringers" />
        </intent-filter>
    </receiver>

    <!-- Service GCM -->
    <service
        android:exported="true"
        android:name="app.cloudstringers.GcmIntentService" />

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

</application>

解决方案: 我把错误路线。应该把&LT;使用-许可&GT; 之外的标签&lt;应用&GT; 标记

SOLUTION I put wrong lines. Should put <use-permission> tag outside of <application> tag.

推荐答案

改成这样:

    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <uses-permission android:name="app.cloudstringers.permission.C2D_MESSAGE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
      <permission
        android:name="app.cloudstringers.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />
    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="app.cloudstringers.Cloudstringers"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity android:name="ui.fragment.RegisterWithAccountsFragment" />

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



    <!-- Receiver GCM -->
    <receiver
        android:name="app.cloudstringers.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="app.cloudstringers" />
        </intent-filter>
    </receiver>

    <!-- Service GCM -->
    <service
        android:exported="true"
        android:name="app.cloudstringers.GcmIntentService" />



</application>

您应该把&LT;使用-许可&GT; 之外的标签&lt;应用&GT; 标记

You should put <use-permission> tag outside of <application> tag.

这篇关于SecurityException异常:不允许启动服务意向的行为= com.google.android.c2dm.intent.REGISTER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆