3
GCM 서비스에 문제가 있습니다.Android GCM ICS에서 작동하지만 진저 브레드에서 작동하지 않습니다.
내 앱은 Android> = 4.0 기기에서 제대로 작동하지만 진저 빵에서는 작동하지 않습니다 (예 :).
나는 문제가 매니페스트 있다고 생각하지만이 표시되는 로그 캣 아무것도에서
public class GCMIntentService extends GCMBaseIntentService {
private static final String TAG = "GCMIntentService";
public GCMIntentService() {
super(SENDER_ID);
Log.d(TAG,"CREATO IL Servizio");
}
/**
* Method called on device registered
**/
@Override
protected void onRegistered(Context context, String registrationId) {
Log.i(TAG, "Device registered: regId = " + registrationId);
displayMessage(context, "Your device registred with GCM");
Log.d("NAME", MainActivity.name);
ServerUtilities.register(context, MainActivity.name, MainActivity.email, registrationId);
/*TODO*/
MainActivity.regId=registrationId;
}
/**
* Method called on device un registred
* */
@Override
protected void onUnregistered(Context context, String registrationId) {
Log.i(TAG, "Device unregistered");
displayMessage(context, getString(R.string.gcm_unregistered));
ServerUtilities.unregister(context, registrationId);
}
/**
* Method called on Receiving a new message
* */
@Override
protected void onMessage(Context context, Intent intent) {
Log.i(TAG, "Received message");
String message = intent.getExtras().getString("price");
displayMessage(context, message);
// notifies user
generateNotification(context, message);
}
/**
* Method called on receiving a deleted message
* */
@Override
protected void onDeletedMessages(Context context, int total) {
Log.i(TAG, "Received deleted messages notification");
String message = getString(R.string.gcm_deleted, total);
displayMessage(context, message);
// notifies user
generateNotification(context, message);
}
/**
* Method called on Error
* */
@Override
public void onError(Context context, String errorId) {
Log.i(TAG, "Received error: " + errorId);
displayMessage(context, getString(R.string.gcm_error, errorId));
}
@Override
protected boolean onRecoverableError(Context context, String errorId) {
// log message
Log.i(TAG, "Received recoverable error: " + errorId);
displayMessage(context, getString(R.string.gcm_recoverable_error,
errorId));
return super.onRecoverableError(context, errorId);
}
}
바로
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maptest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET" />
<permission android:name="com.example.maptest.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.example.maptest.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- Network State Permissions to detect Internet status -->
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!-- Permission to vibrate -->
<uses-permission android:name="android.permission.VIBRATE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:name=".RegisterActivity"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.maptest.MainActivity"
android:label="@string/app_name" >
<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.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" />
<category android:name="MapTest" />
</intent-filter>
</receiver>
<service android:name="com.example.maptest.GCMIntentService" android:enabled="true"/>
</application>
</manifest>
그리고 내 클래스를 보인다.
나를 도와 줄 사람이 있습니까? 감사합니다. 이 com.example.maptest
패키지 이름 인 경우
감사의 같은 수는
에 매니페스트 파일에 선언을해야합니다! 이제는 서비스가 작동하지만 AVD에서 "누락 된 계정"이라는 오류로 저에게 응답한다고 생각합니다. 왜? Google Apis에서 AVD 시스템을 사용하고 있습니다 .- – Name29
이전 Android 버전에서는 푸시 메시징을 작동 시키려면 휴대 전화에 계정으로 로그인해야합니다. "Google 계정에 로그인 한 사용자가 기기가 Android 4.0.4 이하 버전을 실행 중입니다. "- http://developer.android.com/google/gcm/gcm.html#arch –
베타 버전 C2DM에서는 자신을 인증 할 Gmail 계정이 있어야합니다 메시지를 푸시하는 데 사용되는 서비스에 실제 기기 또는 에뮬레이터에 Google Play 앱이 설치되어 있어야합니다. –