Android Application get crashed when application i

2019-09-13 19:24发布

问题:

I am new on Xamarin and android. I am facing issue with my Xamarin Android app. The application is get crashed. when it closed and received a GCM notification from the server. I have applied many configurational changes and update the Manifest.

<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="23" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.packageName.permission.C2D_MESSAGE" />
<permission android:name="com.packagename.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<application android:icon="@drawable/logo" android:label="AppName">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="myKey" />
<supports-screens android:xlargeScreens="true" />

<receiver android:name="com.packagename.PushHandlerService"></receiver>
<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" />
    <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
    <category android:name="com.packagename" />
      <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.BROWSABLE"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:scheme="air.com.packagename.gcm"/>
  </intent-filter>
</receiver>
</application>

Here is the Error Log: PushNotificationRegistationIntentService - Register -
Java.IO.IOException: MISSING_INSTANCEID_SERVICE at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c].

回答1:

I have fixed this issue. I create IntentService instead of Service. https://developer.android.com/reference/android/app/IntentService.html

And I found an example for Intent service: https://developer.xamarin.com/samples/monodroid/RemoteNotifications/