Android Google云消息中的ActivityNotFoundException
我正在android应用程序中开发推送通知。在这一点上:Android Google云消息中的ActivityNotFoundException,android,google-cloud-messaging,android-manifest,intentservice,Android,Google Cloud Messaging,Android Manifest,Intentservice,我正在android应用程序中开发推送通知。在这一点上: if (checkPlayServices()){ Intent intent = new Intent(this, RegistrationIntentService.class); startActivity(intent); } 必须注册设备才能获取令牌并将其发送到服务器,但当我尝试启动活动时,代码崩溃。以下是logcat中显示的错误: java.lang.RuntimeException
if (checkPlayServices()){
Intent intent = new Intent(this, RegistrationIntentService.class);
startActivity(intent);
}
必须注册设备才能获取令牌并将其发送到服务器,但当我尝试启动活动时,代码崩溃。以下是logcat中显示的错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cgp.tpvtablet/com.cgp.tpvtablet.activity.MainActivity}: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.cgp.tpvtablet/com.cgp.tpvtablet.area_push.notification.RegistrationIntentService}; have you declared this activity in your AndroidManifest.xml?
在清单中,RegistrationEventService在其当前包中声明为服务:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:windowSoftInputMode="adjustPan">
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
android:windowSoftInputMode="stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.cgp.tpvtablet"/>
</intent-filter>
</receiver>
<service android:name=".area_push.notification.MyGCMListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service android:name=".area_push.notification.MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service android:name=".area_push.notification.RegistrationIntentService"
android:exported="false"/>
</application>
当我在清单中写入RegistrationEntertService时,编辑器建议我使用此路径。
有人能帮我吗?提前感谢。在您的清单中,主活动有一个相对路径“.activity.MainActivity”,您在清单包属性中放置的基本路径是什么?如果
RegistrationEntService
是一项服务,为什么要使用startActivity(intent)代码>
因为这不是一项活动,所以它不会工作,并且会崩溃
您需要startService
软件包是:com.nvp.testapp