How to fix Google Cloud Messaging Registration error:PHONE_REGISTRATION_ERROR? - android

I encountered a strange problem - I am using GCM with my application for a month but now its has stopped working on my nexus 4 (running Lollipop 5.0.1, stock Android).Everytime I try to get a registration id from Google server it returns me Error :PHONE_REGISTRATION_ERROR .I know this error is for devices that runs android version 2.2 and below as they do not support GCM but why is it happening for my device although it was working few days back.
<permission
android:name="diver.volo.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="diver.volo.permission.C2D_MESSAGE" />
<receiver
android:name="diver.volo.components.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="diver.volo" />
</intent-filter>
</receiver>

Related

android - BOOT_COMPLETED is not working in android version 7.1 and below

I scheduled alarms and i need to reschedule it after reboot the device, it is not working in android 7.1
I have registered receiver in AndroidManifest.xml and permission but no luck. It is working correctly in android 8 and above
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<receiver android:name=".services.StartBootReceiver" android:enabled="false">
<intent-filter>
<actionandroid:name="android.intent.action.QUICKBOOT_POWERON" />
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>

GCM not working on Android 4.1 devices

I'm implementing GCM, wich teorically haves a reasonable requirement, android 2.3: https://developers.google.com/cloud-messaging/android/client
The problem is that it is working in my Android 5.1 devices and Android 4.4 devices, but it does not work in my Android 4.1 devices, LG and HUAWEI....
I can see this error in the logcat: GooglePlayServices not available due to error 2
In the previous link i can see this:
If you want to support pre-4.4 KitKat devices, add the following
action to the intent filter declaration for the receiver:
So i added it, this is what i added in the manifest:
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <!-- GCM requires a Google account. -->
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- Keeps the processor from sleeping when a message is received. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <!-- This app has permission to register and receive data message. -->
<!-- Creates a custom permission so only this app can receive its messages. NOTE: APP_PACKAGE.permission.C2D_MESSAGE -->
<permission android:name="com.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.myapp.permission.C2D_MESSAGE" />
<!-- BroadcastReceiver that will receive intents from GCM services and handle them to the custom IntentService. -->
<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.myapp" />
</intent-filter>
</receiver>
<service
android:name="com.myapp.util.notifications.GCMListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name="com.myapp.util.notifications.CustomInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service
android:name="com.myapp.util.notifications.RegistrationIntentService"
android:exported="false">
</service>
It is very frustrating since both devices are Android 4.1, munch higher than Android 2.3.
Also before this, with my old implementation of GCM (before google play services origins, when GCM was a .jar file called gcm.jar) works 100% fine on these 4.1 devices.
In the device 4.1 you are testing ,firstly you have to update your google play services of device..after that check your logs and show logs so that i can help you?

Cannot register to GCM for push notifications on Android 5 and 5.1

I am developing an AIR application and I implemented push notifications for Android using GCM. The service works perfectly on all devices except those having Android 5.0 or 5.1 OS. The application simply doesn't receive a registration id from GCM.
Neither PERMISSION_GIVEN_WITH_TOKEN_EVENT nor PERMISSION_REFUSED_EVENT are never raised. I am not getting any response from GCM.
Did anybody have this problem? Could you please help me?
I am using Air Native Extension for Push Notifications from Freshplanet github.com/freshplanet/ANE-Push-Notification
So this is my code:
PushNotification.getInstance().registerForPushNotification(GOOGLE_PROJECT_ID); PushNotification.getInstance().addEventListener(PushNotificationEvent.PERMISSION_REFUSED_EVENT, onPushNotificationTokenFailed);
function onPushNotificationToken(event:PushNotificationEvent):void {
trace("My push token is: " + event.token);
}
function onPushNotificationTokenFailed(event:PushNotificationEvent):void
{
trace(event.errorCode);
trace(event.errorMessage);
trace();
}
And my manifest file (partial):
<permission android:name="MY_APP_ID.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="MY_APP_ID.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application>
<activity android:name="com.freshplanet.nativeExtensions.NotificationActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<receiver android:name="com.freshplanet.nativeExtensions.C2DMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="MY_APP_ID" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="MY_APP_ID" />
</intent-filter>
</receiver>
<service android:name="com.freshplanet.nativeExtensions.LocalNotificationService"/>
<receiver android:name="com.freshplanet.nativeExtensions.LocalBroadcastReceiver" android:process=":remote">
</receiver>
Thanks in advance!

Android AccessibilityService compatible to Kindle Fire?

I try to develop an Android application to handle the notifications from other apps and send them to my laptop to notify the user. I use the AccessibilityService to handle the notifications on devices with Android < 4.3 (API Level 18) and the NotificationListenerService for devices with android >= 4.3.
There are no issues getting the notifications on my only android device (Samsung Galaxy S with Android 2.3.3), but I need to activate the App in the accessibility settings.
Now I tried to debug the app on my Kindle Fire (API Level 17) and my apps Activity works fine, but the app is not listed in the accessibility settings of the device. The Amazon App testing service returns no problem, so I dont know where I should search the problem.
Is it possible to use the AccessibilityService on the Kindle Fire?
Here is my android manifest file:
<uses-permission android:name="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"/>
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18"
/>
<application
android:icon="#drawable/ic_launcher"
android:allowBackup="true">
<activity
android:name="de.test.notificationdistributor.SettingsActivity"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name="de.test.notificationdistributor.NotificationDistributorService">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
<service
android:name="de.test.notificationdistributor.NotificationDistributionDeprService">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
</application>
You must add the permission android.permission.BIND_ACCESSIBILITY_SERVICE (added in API 16 - android 4.1)
<service
android:name="de.test.notificationdistributor.NotificationDistributorService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<meta-data android:name="android.accessibilityservice" android:resource="#xml/accessibilityservice" />
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>
In the doc http://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html
Additionally an accessibility service must request the BIND_ACCESSIBILITY_SERVICE permission to ensure that only the system can bind to it. Failure to declare this intent will cause the system to ignore the accessibility service.

GCM Activity getting force closed

I am a beginner with Google cloud messaging. I was developing a demo app to check the functionality of GCm. I have created a GCM project and i am checking whether the device is registered or not. I am using the following code,
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
GCMRegistrar.checkDevice(this);
GCMRegistrar.checkManifest(this);
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
GCMRegistrar.register(this, "483910217912");
Log.d(tag, "Registered");
} else {
Log.v(tag, "Already registered");
}
}
and my Manifest file is,
<uses-sdk android:minSdkVersion="8" />
<!-- App receives GCM messages. -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- GCM connects to Google Services. -->
<uses-permission android:name="android.permission.INTERNET" />
<!-- 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" />
<permission android:name="my_app_package.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="my_app_package.permission.C2D_MESSAGE" />
<application
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<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="my_app_package" />
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
<activity
android:name=".GCmExampleActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
I have included the gsm jar files into my project.
The Logcat error it gives is,
10-11 13:44:59.001: E/AndroidRuntime(339): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kochar.it.GCM/com.kochar.it.GCM.GCmExampleActivity}: java.lang.UnsupportedOperationException: Device does not have package com.google.android.gsf
The error is on the line,
GCMRegistrar.checkDevice(this);
It seems that you're using the wrong emulator. The default emulator uses a regular Android emulator that doesn't have any Google packages and can't run all sorts of things like maps, c2dm and all sorts of stuff like that. What you want to do, is create a new emulator that can support the Google APIs.
Don't run this in an emulator. Because it needs Google account.
Try one of below,
Create Emulator with Google api
Run it on real android phones
Run it on Bluestack (http://bluestacks.com/)
It will solve your problem. :)

Categories

Resources