Ответ 1
Какую ошибку вы получаете?
Это отлично работает для меня:
Манифест библиотеки
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.plasync.client.android"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<!-- Needed for devices with 4.02 or earlier android -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<permission android:name="org.plasync.client.android.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="org.plasync.client.android.permission.C2D_MESSAGE" />
<!-- <uses-permission android:name="com.playsnc.client.android.data.permission.READ_WRITE"/>-->
<application android:label="" android:icon="@drawable/ic_launcher">
<!-- This is the signin activity for plAsync -->
<activity android:name="org.plasync.client.android.AsyncMultiplayerSetupActivity"
android:label="@string/SETUP_ACTIVITY_NAME"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
<!-- This is the intent for getting the local user. Apps that use plAsync must use this
intent to retrieve the local user, or allow the user to signin. Apps should
use startActivityForResult as the sigin activity may require user interaction -->
<intent-filter>
<action android:name="@string/SETUP_ASYNC_MULTIPLAYER_SESSION_ACTION"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<receiver android:name="org.plasync.client.android.gcm.GcmBroadcastReceiver"
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" />
</intent-filter>
</receiver>
<service android:name="org.plasync.client.android.gcm.GcmReceiveIntentLauncher"/>
</application>
</manifest>
Манифест приложения
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.plasync.client.android.testapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="org.plasync.client.android.testapp.AsyncMultiplayerTestAppActivity"
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=".search.FriendSearchActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable"/>
</activity>
<service android:name=".AsyncMultiplayerTestAppMessageReceiver"/>
</application>
</manifest>
Кроме того, я задаюсь вопросом, является ли решение с сервисами и AIDL чрезмерным. Я начал с этого маршрута, но меня отключила сложность межпроцессного общения для моей ситуации. Я смог просто определить службу широковещательного приемника и намерения в своей библиотеке, которая запускает службу намерений в моем приложении. Вам просто нужно быть осторожным с именами пакетов. и имена компонентов. Имя пакета всегда будет именем пакета для вашего приложения, но имя компонента будет именем класса для вашей службы.