Receptor de transmisión de Android UrbanAirship

com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime  java.lang.RuntimeException: Unable to start service com.urbanairship.push.PushService@40cfdc08 with Intent { act=com.urbanairship.push.START cmp=com.myapp.myapp/com.urbanairship.push.PushService }: java.lang.IllegalStateException: UAirship.takeOff() must be called every time Application.onCreate() is invoked.
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2499)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.app.ActivityThread.access$1900(ActivityThread.java:132)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1220)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.os.Handler.dispatchMessage(Handler.java:99)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.os.Looper.loop(Looper.java:137)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.app.ActivityThread.main(ActivityThread.java:4575)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at java.lang.reflect.Method.invokeNative(Native Method)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at java.lang.reflect.Method.invoke(Method.java:511)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at dalvik.system.NativeStart.main(Native Method)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime  Caused by: java.lang.IllegalStateException: UAirship.takeOff() must be called every time Application.onCreate() is invoked.
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at com.urbanairship.push.PushService.onStart(Unknown Source)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.app.Service.onStartCommand(Service.java:438)
23:03:56.422    21926   com.myapp.myapp:com.urbanairship.process    ERROR   AndroidRuntime      at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2482)

Estoy tratando de integrar UrbanAirship en mi aplicación, la excepción anterior aparece después de llamar a takeOff, si modifico la línea:

<service android:name="com.urbanairship.push.PushService" android:process=":com.urbanairship.process"/>

.. para quedarse sin la parte android:process, funciona, pero cuando llega el mensaje push, no se llama a mi PushBroadcastReceiver (no se alcanza el punto de interrupción)

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          android:versionName="3.61 beta 1"
          android:versionCode="71"
          android:installLocation="auto" package="com.myapp.myapp">

    <uses-sdk android:minSdkVersion="3"
            android:targetSdkVersion="4"/>


    <uses-feature android:name="android.hardware.camera"/>
    <application 
        android:label="@string/app_name">
        <activity android:name=".client.android.SplashScreen"
              android:screenOrientation="portrait"
              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=".client.android.CaptureActivity"
              android:screenOrientation="landscape"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
              android:windowSoftInputMode="stateAlwaysHidden">
            <intent-filter>
                <action android:name="com.myapp.myapp.client.android.CaptureActivity" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
        <activity android:name=".client.android.PreferencesActivity"
              android:label="@string/preferences_name"
              android:screenOrientation="portrait">

        </activity>

        <activity android:name=".client.android.PushBroadcastReceiver">

        </activity>

        <activity android:name=".client.android.AboutActivity"
              android:label="@string/menu_about">
            <intent-filter>
                <action android:name="com.myapp.myapp.client.android.AboutActivity" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

        </activity>

        <receiver android:name="com.urbanairship.CoreReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
                <action android:name="android.intent.action.ACTION_SHUTDOWN" />
            </intent-filter>
        </receiver>

        <receiver android:name="com.urbanairship.push.c2dm.C2DMPushReceiver"
              android:permission="com.google.android.c2dm.permission.SEND">

            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <category android:name="com.myapp.myapp" />
            </intent-filter>

            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="com.myapp.myapp" />
            </intent-filter>

        </receiver>

        <service android:name="com.urbanairship.push.PushService" android:process=":com.urbanairship.process"/>
        <receiver android:name="com.myapp.myapp.client.android.PushBroadcastReceiver" />

    </application>


    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.READ_CONTACTS"/>
    <uses-permission android:name="android.permission.WRITE_CONTACTS"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.FLASHLIGHT"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.BROADCAST_STICKY" />


    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <permission android:name="com.myapp.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="com.myapp.myapp.permission.C2D_MESSAGE" />

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

</manifest>

preguntado el 12 de junio de 12 a las 21:06

1 Respuestas

¿Desde dónde llamas a takeOff? Parece que no está usando AutoPilot o proporcionando una aplicación personalizada que llame al despegue en el método onCreate.

Primero cree una clase CustomApplication que llame a takeOff:

public class CustomApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        // Optionally, customize your config at runtime:
        //
        // AirshipConfigOptions options = new AirshipConfigOptions();
        // options.inProduction = false;
        // options.developmentAppKey = "Your Development App Key";
        // options.developmentAppSecret "Your Development App Secret";
        //
        // UAirship.takeOff(this, options);

        UAirship.takeOff(this, new UAirship.OnReadyCallback() {
            @Override
            public void onAirshipReady(UAirship airship) {
                // Perform any airship configurations here
            }
        });
    }
}

Luego configure la aplicación en el manifiesto: <application name="CustomApplication"

También eliminaría el uso de procesos de su manifiesto. Casi nunca son una buena idea para usar más. Complicarán la lógica de la aplicación y desperdiciarán más recursos.

Para más información sobre Urban Airship - http://docs.urbanairship.com/platform/android.html.

Respondido 03 Feb 15, 00:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.