android - google cloud messaging receiver error -
when send message app, message:
08-12 22:17:12.932: w/gtalkservice(475): [datamsgmgr] broadcast intent callback: result=cancelled forintent { act=com.google.android.c2dm.intent.receive pkg=com.example.databasetest (has extras) } 08-12 22:17:12.932: w/gtalkservice(475): receiver package not found, unregister application com.example.databasetest sender
it seems message must sending ok if app picks on trying receive something. manifest sensitive values omitted:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.databasetest" android:versioncode="1" android:versionname="1.0" > <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_fine_location" /> <uses-permission android:name="android.permission.access_course_location" /> <uses-permission android:name="com.google.android.providers.gsf.permission.read_gservices" /> <uses-permission android:name="android.permission.write_external_storage" /> <uses-permission android:name="android.permission.get_accounts" /> <uses-permission android:name="android.permission.wake_lock"/> <uses-sdk android:minsdkversion="12" android:targetsdkversion="17" /> <uses-feature android:glesversion="0x00020000" android:required="true"/> <permission android:name="com.example.databasetest.permission.maps_receive" android:protectionlevel="signature"/> <uses-permission android:name="com.google.android.c2dm.permission.receive"/> <uses-permission android:name="com.example.databasetest.permission.maps_receive" /> <permission android:name="com.example.databasetest.permission.c2d_message" android:protectionlevel="signature"/> <uses-permission android:name="com.example.databasetest.permission.c2d_message" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme" > <meta-data android:name="com.google.android.maps.v2.api_key" android:value="value"/> <activity android:name=".login" 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=".mainactivity" android:label="@string/app_name"> </activity> <receiver android:name="com.example.databasetest.gcmreceiver" android:permission="com.google.android.c2dm.permission.send"> <intent-filter> <action android:name="com.google.anroid.c2dm.permission.receive"/> <action android:name="com.google.anroid.c2dm.permission.registration"/> <category android:name="com.example.databasetest"/> </intent-filter> </receiver> </application> </manifest>
and receive method in file, gcmreceiver.java, seems in right place. log never called.
@override public void onreceive(context context, intent intent) //receives messages server { string action = intent.getaction(); log.d("im", "receive : "+action); if(action.equals("com.google.android.c2dm.intent.registration")) //get unique registration id server { string registrationid = intent.getstringextra("registration_id"); string error = intent.getstringextra("error"); log.d("im", "registered: " + registrationid); if(error != null && !error.isempty()) { log.d("im", "error: " + error); } } else if(action.equals("com.google.android.c2dm.intent.receive")) //or receive message server { log.d("im", "im receiving"); if((connector != null) && (connector.loc != null) ) //make sure gps location available { string name = intent.getstringextra("username"); string message = intent.getstringextra("message"); double lati = intent.getextras().getdouble("latitude"); double longi = intent.getextras().getdouble("longitude"); messages.add(new message(name, message, lati, longi)); chatadapter.notifydatasetchanged(); } } }
Comments
Post a Comment