I am using google push notifications, it worked perfectly until now,
At the moment the push notifications doesnt work beacause onRegistered is never launched. I think the problem is in the manifest(since the problem is that the receiver is never called) but I'm not sure
this is my manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.name.name"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RESTART_PACKAGES"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.name.name.permission.C2D_MESSAGE" android:protectionLevel="normal" />
<application
android:allowBackup="true"
android:icon="#drawable/logo"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.name.name.Disclaimer"
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="com.name.name.Pago"
>
</activity>
<activity android:name="com.name.name.MainActivity" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.NoMiembros" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.ZonaMiembros" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.PlayvideofromserverActivity" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.GoPromo" android:screenOrientation="portrait"></activity>
<activity android:name="com.name.name.PantallaCarga" android:screenOrientation="portrait"></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="com.name.name" />
</intent-filter>
</receiver>
<receiver android:name=".SMSHandler$MessageReceiver" android:exported="true">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED"></action>
</intent-filter>
</receiver>
<service android:name=".GCMIntentService" />
</application>
</manifest>
Try changing this :
<uses-permission android:name="com.name.name.permission.C2D_MESSAGE"
android:protectionLevel="normal" />
To this :
<permission android:name="com.name.name.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.name.name.permission.C2D_MESSAGE" />
i'm not sure where the crossover stops, but i'm using C2DM instead of GCM still, and I'm declaring my message and registration receivers as local classes, not pointing to the google classes like you are.
<receiver
android:name=".utils.C2DMRegistrationReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.REGISTRATION" >
</action>
<category android:name="package.name.here" />
</intent-filter>
</receiver>
<receiver
android:name=".utils.C2DMMessageReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" >
</action>
<category android:name="package.name.here" />
</intent-filter>
</receiver>
Related
My app successfully auto start in some devices like Sony Xperia, OnePlus 3, Lyf, Micromax. But doesn't in Xiaomi. Then I found on StackOverflow that I have to give auto-start permissions to my app in Xiaomi Built-in Startup manager. I have also done that but my app doesn't auto-start. Here is the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.missingcell.trackerapp"
android:installLocation="internalOnly">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.READ_CALL_LOG" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!-- for card.io card scanning -->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<application
android:name="com.missingcell.trackerapp.AppController"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyApCFp8fEsll0RO114zLWKQQ6EexTM488c" />
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.missingcell.trackerapp.activities.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="com.missingcell.trackerapp.activities.ChildDetails"
android:label="#string/title_activity_second">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.missingcell.trackerapp.MainActivity" />
</activity>
<service
android:name="com.paypal.android.sdk.payments.PayPalService"
android:exported="false" />
<activity android:name="com.paypal.android.sdk.payments.PaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.LoginActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentMethodActivity" />
<activity android:name="com.paypal.android.sdk.payments.PaymentConfirmActivity" />
<activity android:name="com.paypal.android.sdk.payments.PayPalFuturePaymentActivity" />
<activity android:name="com.paypal.android.sdk.payments.FuturePaymentConsentActivity" />
<activity android:name="com.paypal.android.sdk.payments.FuturePaymentInfoActivity" />
<activity android:name="com.paypal.android.sdk.payments.PayPalProfileSharingActivity" />
<activity android:name="com.paypal.android.sdk.payments.ProfileSharingConsentActivity" />
<activity
android:name="io.card.payment.CardIOActivity"
android:configChanges="keyboardHidden|orientation" />
<activity android:name="io.card.payment.DataEntryActivity" />
<activity android:name="com.missingcell.trackerapp.MainActivity"></activity>
<activity android:name="com.missingcell.trackerapp.activities.RegisterActivity"></activity>
<activity android:name="com.missingcell.trackerapp.activities.BuyPro"></activity>
<receiver android:name="com.missingcell.trackerapp.call.AlarmReceiver">
<intent-filter android:priority="9991000">
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<action android:name="android.intent.action.PHONE_STATE" />
<action android:name="in.deepakpandey.AlarmReceiver"></action>
</intent-filter>
</receiver>
<receiver android:name="com.missingcell.trackerapp.sms.SMSReceiver">
<intent-filter android:priority="9991000">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.provider.Telephony.SMS_SENT" />
<action android:name="in.deepakpandey.SMSReceiver" />
</intent-filter>
</receiver>
<receiver
android:name=".gps.GpsTrackerBootReceiver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="com.missingcell.trackerapp.gps.GPSReciver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<receiver
android:name="com.missingcell.trackerapp.utils.APIReciver"
android:enabled="true"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter android:priority="9991000">
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="com.missingcell.trackerapp.utils.NotificationReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
</intent-filter>
</receiver>
<receiver
android:name="com.missingcell.trackerapp.utils.DemoDeviceAdmin"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
<!-- This is required this receiver to become device admin component. -->
<meta-data
android:name="android.app.device_admin"
android:resource="#xml/device_admin" />
</receiver>
<service
android:name="com.tuenti.smsradar.SmsRadarService"
android:exported="false"
android:label="#string/app_name" />
</application>
</manifest>
It doesn't new on Xiaomi because Xiaomi has a feature called app permission, where a user has to allow the app to start automatically (Service). In your case the Service is not called, once its terminated from stack.
Go like this and allow your app to autostart:
Settings > permissions > Autostart
Code:
if (Build.BRAND.equalsIgnoreCase("xiaomi")) {
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"));
startActivity(intent);
}
Use the above code to launch autostart activity.
I have a launcher activity but android studio says "Default activity not found". This started after I added a login activity which I wanted it to be the launcher activity (meant for when the user signs up only). So I would like the Main activity to be the launcher activity once the user installs my app and provide their credentials. Your help is much appreciated.
This is my manifest with both my login and main activities.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mypackage"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<library />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.BATTERY_STATS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="mypackage.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="otherpackage.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="mypackage.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<permission
android:name="com.google.android.c2dm.permission.RECEIVE"></permission>
<permission
android:name="otherpackage.permission.C2D_MESSAGE"
android:protectionLevel="signature"></permission>
<application
android:allowBackup="true"
android:icon="#drawable/image"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="key"/>
<Activity
android:name=".Login"
android:label="REGISTER"
android:noHistory="true">
<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" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</Activity>
<Activity
android:name=".MapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAPACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</Activity>
<!--<activity
android:name=".MyMapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MYMAPACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>-->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!--Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!--this is to support pre KitKat -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="mypackage" />
<category android:name="otherpackage" />
</intent-filter>
</receiver>
<receiver android:name=".MapActivity$ResponseReceiver">
<intent-filter>
<action android:name="mypackage.MapActivity.ResponseReceiver.ACTION_RESP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service
android:name=".MapActivity$MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".Login$MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service android:name="mypackage.RegistrationIntentService"></service>
<service
android:name=".FetchAddressIntentService"
android:exported="false"/>
</application>
</manifest>
This is the main activity.
public class MainActivity extends MapActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(MainActivity.this, MapActivity.class);
startActivity(i);
}
}, 8000);
}
}
N.B The main activity extends my MapActivity, which extends FragmentActivity. It is starnge but I found this in logcat. I haven't implemented iheartradio library or anything. "Caused by: java.lang.ClassNotFoundException: com.clearchannel.iheartradio.alarm.LiveDeltaUpdateService"
change Activity to activity in manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="mypackage"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<library />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.BATTERY_STATS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="mypackage.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="otherpackage.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
<permission
android:name="mypackage.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<permission
android:name="com.google.android.c2dm.permission.RECEIVE"></permission>
<permission
android:name="otherpackage.permission.C2D_MESSAGE"
android:protectionLevel="signature"></permission>
<application
android:allowBackup="true"
android:icon="#drawable/image"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="key"/>
<activity
android:name=".Login"
android:label="REGISTER"
android:noHistory="true">
<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" >
<intent-filter>
<action android:name="android.intent.action.MAINACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".MapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAPACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!--<activity
android:name=".MyMapActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MYMAPACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>-->
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<!--Receives the actual messages. -->
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<!--this is to support pre KitKat -->
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="mypackage" />
<category android:name="otherpackage" />
</intent-filter>
</receiver>
<receiver android:name=".MapActivity$ResponseReceiver">
<intent-filter>
<action android:name="mypackage.MapActivity.ResponseReceiver.ACTION_RESP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<service
android:name=".MapActivity$MyGcmListenerService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<service
android:name=".Login$MyInstanceIDListenerService"
android:exported="false">
<intent-filter>
<action android:name="com.google.android.gms.iid.InstanceID"/>
</intent-filter>
</service>
<service android:name="mypackage.RegistrationIntentService"></service>
<service
android:name=".FetchAddressIntentService"
android:exported="false"/>
</application>
</manifest>
You have a typo. <activity>, not <Activity>
A full AndroidManifest must contain the tag and the inside it.
You must declare the Activity with its fully qualified class name, and the package declaration can be ommited with a dot (.) if the Activity is inside the package of the application (declared at manifest.package attribute)
Such:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="br.com."
android:versionCode="1"
android:versionName="2.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="11" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_OWNER_DATA" />
<uses-permission android:name="android.permission.READ_OWNER_DATA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.android.vending.BILLING" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
<application
android:name=".BvApplication"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:icon="#drawable/icon"
android:label="#string/app_name" >
<activity
android:name=".BvNewsstandActivity"
android:launchMode="singleTop"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<activity
android:name=".LoginActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="br.com.digitalpages.reader.activity.HelpActivity"
android:theme="#style/Transp" />
<activity
android:name="br.com.digitalpages.reader.ReaderActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
<activity
android:name="br.com.digitalpages.commons.activity.LoadingActivity"
android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
<activity
android:name="br.com.digitalpages.commons.activity.WebActivity"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" />
</application>
PS: You MUST read the stack trace generated from the error while running the application, you can use the logcat window at Eclipse or Android Studio or the Android Device Monitor included in the Android SDK installation.
You can try this:
File->Invalidate Caches->Restart
Simply deleting the .gradle folder in C://Users/username did it for me. Invalidating caches etc didn't.
I am attempting to set up push notifications for my application. I have followed the appropriate quickstart guide and the tutorial and have, as far as I can tell, set everything up correctly, but when I run the app I get the following LogCat error:
E/com.parse.ManifestInfo(17775): Cannot use GCM for push because the app manifest is missing some required declarations. Please make sure that these permissions are declared as children of the root <manifest> element:
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.INTERNET" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.VIBRATE" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.WAKE_LOCK" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="android.permission.GET_ACCOUNTS" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
E/com.parse.ManifestInfo(17775): <permission android:name="com.example.myapp.permission.C2D_MESSAGE" android:protectionLevel="signature" />
E/com.parse.ManifestInfo(17775): <uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
E/com.parse.ManifestInfo(17775): Also, please make sure that these services and broadcast receivers are declared as children of the <application> element:
E/com.parse.ManifestInfo(17775): <service android:name="com.parse.PushService" />
E/com.parse.ManifestInfo(17775): <receiver android:name="com.parse.GcmBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND">
E/com.parse.ManifestInfo(17775): <intent-filter>
E/com.parse.ManifestInfo(17775): <action android:name="com.google.android.c2dm.intent.RECEIVE" />
E/com.parse.ManifestInfo(17775): <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
E/com.parse.ManifestInfo(17775): <category android:name="com.example.myapp" />
E/com.parse.ManifestInfo(17775): </intent-filter>
E/com.parse.ManifestInfo(17775): </receiver>
Here's the relevant excerpt from my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<permission android:name="com.example.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<!-- activities excluded to be concise -->
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.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="com.example.myapp" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.parsePushBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="#drawable/push_icon" />
</application>
</manifest>
I've double and triple checked and it seems like I have everything that the error is saying I need. Is there something obvious that I'm missing here?
Other possibly relevant information:
My launcher activity
public class StartActivity extends ActionBarActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Parse.initialize(this, "REDACTED", "REDACTED");
ParsePush.subscribeInBackground("");
ParseUser user = ParseUser.getCurrentUser();
Intent i;
if (user == null) {
i = new Intent(this, LogInActivity.class);
} else {
i = new Intent(this, MainActivity.class);
}
startActivity(i);
finish();
}
}
There is not currently anything related to pushes in any of my other classes. One possibility I haven't tested yet is that my lack of a ParsePushBroadcastReceiver subclass is causing a problem, but based on the documentation in the Parse API, this doesn't seem to be necessary for the basic push service.
My full manifest, in case it's needed:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<permission android:name="com.example.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.myapp.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name=".LogInActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
</activity>
<activity
android:name=".ChatActivity"
android:label="#string/app_name"
android:windowSoftInputMode="stateHidden" >
</activity>
<activity
android:name=".StartActivity"
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="com.parse.PushService" />
<receiver android:name="com.parse.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="com.example.myapp" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.ParsePushBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver android:name="com.parse.parsePushBroadcastReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<meta-data
android:name="com.parse.push.notification_icon"
android:resource="#drawable/push_icon" />
</application>
</manifest>
I'll happily provide any more information that's requested, this is all I could think of. Thanks in advance for any help.
Welp. After all the time I spent on this, it turns out I was just another victim of a typo. Although, I don't actually know what the typo was... I ended up just copy+pasting the error log into my manifest and erasing the timestamp (leaving just the suggested code) and using that to replace the relevant lines. I still can't see a difference, but it's working now. I feel pretty ridiculous.
I can only get null for the messageType when I called the function gcm.getMessageType(intent) in the class which I extended the IntentService. I'm sure the intent parameter is the intent I received in your BroadcastReceiver.
In the page GCM returns a null message type they said the problem is more or less related to the manifest file, but I checked my file and could not find the reason. The example I use is from http://www.grokkingandroid.com/?s=gcm&x=0&y=0.
My AndroidManifest.xml is provided as below. Much appreciated if someone can help me to figure it out. I am stuck in this problem for several days.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.grokkingandroid.sampleapp.samples.gcm"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.INTERNET" />
<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="com.grokkingandroid.sampleapp.samples.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.grokkingandroid.sampleapp.samples.gcm.permission.C2D_MESSAGE" />
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/gcm_demo_app_name"
android:theme="#style/DemoAppTheme" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name="com.grokkingandroid.sampleapp.samples.gcm.GCMDemoActivity"
android:label="#string/gcm_demo_title_activity_gcm_demo" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.grokkingandroid.sampleapp.ACTION_START" />
<data
android:host="grokkingandroid.com"
android:path="/samples/gcm demo"
android:scheme="app" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.grokkingandroid.sampleapp.samples.alert.AlertListActivity"
android:label="#string/Emergency_warning" >
</activity>
<activity
android:name="com.grokkingandroid.sampleapp.samples.description.DescriptionActivity"
android:exported="false"
android:label="#string/gcm_demo_title_activity_description" />
<receiver
android:name="com.grokkingandroid.sampleapp.samples.gcm.GcmBroadcastReceiver"
android:exported="true"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.grokkingandroid.sampleapp.samples.gcm" />
</intent-filter>
</receiver>
<service android:name="com.grokkingandroid.sampleapp.samples.gcm.GcmIntentService" />
</application>
I build a push client app using Parse.com SDK.
I can receive push messages on Nexus 5 and 7 which both have Android OS v4.4.2.
But I can't receive push messages on older devices like Samsung Galaxy Ace (v2.3.5)
Here is my AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.me.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="9" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!--
IMPORTANT: Change "com.parse.starter.permission.C2D_MESSAGE" in the lines below
to match your app's package name + ".permission.C2D_MESSAGE".
-->
<permission
android:name="com.me.myapp.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.me.myapp.permission.C2D_MESSAGE" />
<application
android:name="WolApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.me.myapp.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>
<service android:name="com.parse.PushService" />
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.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" />
<!-- IMPORTANT: Change "com.parse.starter" to match your app's package name. -->
<category android:name="com.me.myapp" />
</intent-filter>
</receiver>
<receiver
android:name="com.me.myapp.MyCustomReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.me.myapp.UPDATE_STATUS" />
</intent-filter>
</receiver>
</application>
</manifest>