0

Я разрабатываю push-уведомления в приложении для Android. На данный момент:ActivityNotFoundException в облачных сообщениях Google

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? 

В манифесте RegistrationIntentService объявлен в качестве службы в его текущем пакете:

<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> 

Редактор предложить мне этот путь, когда я пишу RegistrationIntentService в манифест. Может ли кто-нибудь мне помочь? Заранее спасибо.

ответ

0

Если RegistrationIntentService это услуга, почему вы используете startActivity(intent);

с момента его не деятельность он не будет работать и приведет к краху

вам нужно startService

0

В вашем манифесте основное действие имеет относительный путь «.activity.MainActivity», каков базовый путь, который вы добавили в атрибут пакета манифеста?

+0

Пакет: com.nvp.testapp – Viherbar

Смежные вопросы