I'm recieving the above error when deploying my Xamarin Android application using Visual Studio in debug mode, the compile process completes fine but I can't deploy.
The app runs fine in Android 8.1.0 but not in any other lower version.
Error:
>Project "Empresa1.SMPay.Target.Droid.csproj" (Install target(s)):
>C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.0-rc1\zipalign.exe 4 "E:\HenkoTI\Empresa1\SMPay\src\mpay\app\Empresa1.SMPay.Target.Droid\obj\Debug\android\bin\br.com.henkoti.empresaum.smpay.apk" "bin\Debug\\br.com.henkoti.empresaum.smpay-Signed.apk"
>C:\Program Files (x86)\Android\android-sdk\build-tools\28.0.0-rc1\apksigner.BAT sign --ks "C:\Users\rodri\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 18 --max-sdk-version 27 bin\Debug\br.com.henkoti.empresaum.smpay-Signed.apk
>Unexpected install output: pkg: /data/local/tmp/br.com.henkoti.empresaum.smpay-Signed.apk
>Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
>
> at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
> at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass94_0.<InstallPackage>b__0(Task`1 t)
> at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
> at System.Threading.Tasks.Task.Execute()
>Done building project "Empresa1.SMPay.Target.Droid.csproj".
>Build succeeded.
>Unexpected install output: pkg: /data/local/tmp/br.com.henkoti.empresaum.smpay-Signed.apk
>Failure [INSTALL_PARSE_FAILED_MANIFEST_MALFORMED]
>
> at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)
> at Mono.AndroidTools.AndroidDevice.<>c__DisplayClass94_0.<InstallPackage>b__0(Task`1 t)
> at System.Threading.Tasks.ContinuationTaskFromResultTask`1.InnerInvoke()
> at System.Threading.Tasks.Task.Execute()
AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.henkoti.empresaum.smpay" android:installLocation="auto" android:versionName="20181108.0" android:versionCode="4">
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BIND_NFC_SERVICE" />
<uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
<application android:icon="#drawable/ic_launcher" android:theme="#style/MainTheme" android:label="SIGO" android:allowBackup="true" android:fullBackupContent="#xml/my_backup_rules">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths" />
</provider>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id" />
</application>
</manifest>
Compiled AndroidManifest - Obj Folder
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="br.com.henkoti.empresaum.smpay" android:installLocation="auto" android:versionName="20181108.0" android:versionCode="4">
<uses-sdk android:minSdkVersion="18" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BIND_NFC_SERVICE" />
<uses-feature android:name="android.hardware.nfc.hce" android:required="true" />
<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-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature android:name="android.hardware.location.network" />
<application android:icon="#drawable/ic_launcher" android:theme="#style/MainTheme" android:label="SIGO" android:allowBackup="true" android:fullBackupContent="#xml/my_backup_rules" android:name="md5eaa617bc1882abd453813d82db97fb16.MainApplication" android:debuggable="true">
<provider android:name="android.support.v4.content.FileProvider" android:authorities="br.com.henkoti.empresaum.smpay.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="#xml/file_paths" />
</provider>
<meta-data android:name="com.facebook.sdk.ApplicationId" android:value="#string/facebook_app_id" />
<service android:enabled="true" android:exported="true" android:name="Empresa1.SMPay.HCECardService" android:permission="android.permission.BIND_NFC_SERVICE">
<meta-data android:name="android.nfc.cardemulation.host_apdu_service" android:resource="#xml/aid_list" />
<intent-filter>
<action android:name="android.nfc.cardemulation.action.HOST_APDU_SERVICE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</service>
<activity android:configChanges="orientation|screenSize" android:launchMode="standard" android:screenOrientation="portrait" android:theme="#style/MainTheme" android:name="md5eaa617bc1882abd453813d82db97fb16.MainActivity" />
<activity android:icon="#drawable/ic_launcher" android:label="SIGO" android:noHistory="true" android:screenOrientation="portrait" android:theme="#style/SplashTheme" android:name="md5eaa617bc1882abd453813d82db97fb16.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:enabled="true" android:label="Connectivity Plugin Broadcast Receiver" android:name="md592d74be4bac08a7af63848ae15d2f86e.ConnectivityChangeBroadcastReceiver" />
<activity android:configChanges="orientation|screenSize" android:name="md5cf4be63b82b35b5ba951617c70f88a94.FilePickerActivity" />
<activity android:configChanges="orientation|screenSize" android:name="md591f613f6733d8b6e91e929a922515c0e.MediaPickerActivity" />
<receiver android:enabled="true" android:exported="false" android:name="md5b60ffeb829f638581ab2bb9b1a7f4f3f.PowerSaveModeBroadcastReceiver" />
<provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="2147483647" android:authorities="br.com.henkoti.empresaum.smpay.mono.MonoRuntimeProvider.__mono_init__" />
<!--suppress ExportedReceiver-->
<receiver android:name="mono.android.Seppuku">
<intent-filter>
<action android:name="mono.android.intent.action.SEPPUKU" />
<category android:name="mono.android.intent.category.SEPPUKU.br.com.henkoti.empresaum.smpay" />
</intent-filter>
</receiver>
<activity android:name="com.facebook.FacebookActivity" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" android:theme="#style/com_facebook_activity_theme" />
<activity android:name="com.facebook.CustomTabMainActivity" />
<!--
The initialization ContentProvider will call FacebookSdk.sdkInitialize automatically
with the application context. This config is merged in with the host app's manifest,
but there can only be one provider with the same authority activated at any given
point; so if the end user has two or more different apps that use Facebook SDK, only the
first one will be able to use the provider. To work around this problem, we use the
following placeholder in the authority to identify each host application as if it was
a completely different provider.
-->
<provider android:name="com.facebook.internal.FacebookInitProvider" android:authorities="br.com.henkoti.empresaum.smpay.FacebookInitProvider" android:exported="false" />
<activity android:name="com.google.android.gms.auth.api.signin.internal.SignInHubActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:excludeFromRecents="true" android:exported="false" />
<!--Service handling Google Sign-In user revocation. For apps that do not integrate with
Google Sign-In, this service will never be started.-->
<service android:name="com.google.android.gms.auth.api.signin.RevocationBoundService" android:exported="true" android:permission="com.google.android.gms.auth.api.signin.permission.REVOCATION_NOTIFICATION" />
<activity android:name="com.google.android.gms.common.api.GoogleApiActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar" android:exported="false" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
</application>
</manifest>
SplashActivity
using Android.OS;
using Android.App;
using Android.Content.PM;
namespace Empresa1.SMPay.Target.Droid
{
[Activity(Label = "SIGO",
Icon = "#drawable/ic_launcher",
Theme = "#style/SplashTheme",
MainLauncher = true,
NoHistory = true,
ScreenOrientation = ScreenOrientation.Portrait)]
public class SplashActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.StartActivity(typeof(MainActivity));
}
}
}
MainActivity
using System.Net;
using Android.App;
using Android.OS;
using Android.Content;
using Android.Content.PM;
using Xamarin.Forms;
using Xamarin.Facebook;
using Plugin.Toasts;
using Plugin.Permissions;
using Acr.UserDialogs;
using Autofac;
using Empresa1.SMPay.Application;
using Empresa1.SMPay.Application.IoC;
using Empresa1.SMPay.Target.Droid.Services;
using Empresa1.SMPay.Infra.Platform.Services;
using Android.Gms.Auth.Api;
using InteractiveAlert;
using Xfx;
using FFImageLoading.Forms.Droid;
namespace Empresa1.SMPay.Target.Droid
{
[Activity(Theme = "#style/MainTheme",
LaunchMode = LaunchMode.Multiple,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation,
ScreenOrientation = ScreenOrientation.Portrait)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
// Facebook
FacebookSdk.SdkInitialize(this.ApplicationContext);
global::Xamarin.Forms.Forms.Init(this, bundle);
// Calendar
XamForms.Controls.Droid.Calendar.Init();
// SSL
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
// Permissions
Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, bundle);
// Toast
DependencyService.Register<ToastNotification>();
ToastNotification.Init(this);
// Dialogs
UserDialogs.Init(() => (Activity)Forms.Context);
InteractiveAlerts.Init(() => this);
// XfxControls
XfxControls.Init();
// FFImageLoading
CachedImageRenderer.Init(true);
LoadApplication(new Empresa1.SMPay.Application.App(new Setup(this.ApplicationContext, this, TelephonyService)));
}
protected override void OnStart()
{
base.OnStart();
}
protected override void OnResume()
{
base.OnResume();
}
protected override void OnPause()
{
base.OnPause();
}
protected override void OnStop()
{
base.OnStop();
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, Permission[] grantResults)
{
PermissionsImplementation.Current.OnRequestPermissionsResult(requestCode, permissions, grantResults);
//base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
base.OnActivityResult(requestCode, resultCode, data);
if (App.FacebookSinging)
{
// facebook auth
var facebookService = IoCContainer.Container.Resolve<IFacebookService>();
if (facebookService != null)
{
(facebookService as DroidFacebookService)._callbackManager.OnActivityResult(requestCode, (int)resultCode, data);
}
}
else if (App.GoogleSinging)
{
// google auth
if (requestCode == 1)
{
var result = Auth.GoogleSignInApi.GetSignInResultFromIntent(data);
DroidGoogleService.Instance.OnAuthCompleted(result); // TODO
}
}
}
}
}
Anyone here knows, what do i need to do?
I took some screenshots to add here:
Finally I was able to solve the problem, the solution was to change the prefix name of the HCECardService to lowecase.
Before: Empresa1.SMPay.HCECardService
After: empresa1.smpay.HCECardService
[Service(Exported = true, Enabled = true, Permission = "android.permission.BIND_NFC_SERVICE", Name = "empresa1.smpay.HCECardService"), IntentFilter(new[] { "android.nfc.cardemulation.action.HOST_APDU_SERVICE" }, Categories = new[] { "android.intent.category.DEFAULT" }),
MetaData("android.nfc.cardemulation.host_apdu_service", Resource = "#xml/aid_list")]
public class HCECardService : HostApduService
{ ... }
Related
I just updated the latest Parse SDK (1.11.0) and now I'm not receiving push notifications. I am able to register successfully and can see on the parse site that that my "developer" channel has been subscribed but pushes never get sent and I get this error:
PPNS - Outdated device - The records on this installation are
outdated, the user might have uninstalled the app.
Can someone please take a look at my code and see if you notice anything incorrect?
public class LSIApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Parse.initialize(this, "********", "********");
ParseInstallation.getCurrentInstallation().saveInBackground();
ParsePush.subscribeInBackground("developer", new SaveCallback() {
#Override
public void done(ParseException e) {
if (e == null) {
Log.d("com.parse.push", "successfully subscribed to the broadcast channel.");
} else {
Log.e("com.parse.push", "failed to subscribe for push", e);
}
}
});
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
}
}`
Android Manifest:
<?xml version="1.0" encoding="utf-8"?>
<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" />
<permission
android:name="${applicationId}.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="${applicationId}.maps.permission.MAPS_RECEIVE" />
<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="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<permission android:protectionLevel="signature"
android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<application android:name=".LSIApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
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="********" />
<service android:name="com.parse.PushService" />
<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>
<receiver android:name=".startup.PushBroadcastReceiver"
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>
</application>
Note: The ${applicationId} is 'com.broker.schlisimobile.dev' and/or 'com.broker.schlisimobile' depending on whether it's a production or developer build.
Here is my custom PushBroadcastReceiver class:
public class PushBroadcastReceiver extends ParsePushBroadcastReceiver {
#Override
protected void onPushOpen(Context context, Intent intent) {
if ( storyJSONExists(intent) ) {
if (!DataController.getInstance().getCurrentUser().isGuestUser() ) {
Intent i = new Intent(context, PushLoadingActivity.class);
i.putExtras(intent.getExtras());
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
} else {
Intent i = new Intent(context, HomeActivity.class);
i.putExtra("promptForLogin", true);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(i);
}
} else {
Intent i = new Intent(context, HomeActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtras(i);
context.startActivity(i);
}
}
private boolean storyJSONExists(Intent intent) {
try {
String jsonString = intent.getExtras().getString("com.parse.Data");
JSONObject json = new JSONObject(jsonString);
if ( json.has("postID") ) {
return true;
}
} catch (JSONException jsonE) {
jsonE.printStackTrace();
}
return false;
}
}
In your manifest.xml comment/delete below code,
<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>
then add below code in manifest.xml
<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="your_application_id" />
</intent-filter>
</receiver>
hope it works.
I was updating my app to new GCM 7.5 while I noticed thatgoogle changed lot of things.
take a look at my code
public class GcmIntentService extends GcmListenerService {
public static final int NOTIFICATION_ID = 1;
private static final String TAG = "MyGcmListenerService";
public GcmIntentService() {
super();
}
#Override
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
String message2 = data.getString("payload");
String title = data.getString("title");
String type = data.getString("push_type");
Log.i(TAG, "Message: " + message2 + " PushType:" + type + "title" + title);
for (String key : data.keySet())
{
Log.d("Bundle Debug", key + " = \"" + data.get(key) + "\"");
}
// parseMessage(data);
// sendNotification(message);
}
#Override
public void onDeletedMessages() {
// sendNotification("Deleted messages on server");
}
#Override
public void onMessageSent(String msgId) {
// sendNotification("Upstream message sent. Id=" + msgId);
}
#Override
public void onSendError(String msgId, String error) {
// sendNotification("Upstream message send error. Id=" + msgId + ", error" + error);
}
Now into my problem: The data recieved is null except I logged the bundle there was a collapsekey too.
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.was.abcd"
android:versionCode="404080000"
android:versionName="4.8.0" >
<supports-screens
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="19" />
<!-- * Google Cloud Messaging -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<permission
android:name="com.was.abcd.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.was.abcd.permission.C2D_MESSAGE" />
<!-- Google Cloud Messaging * -->
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application
android:allowBackup="false"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:largeHeap="#bool/largeheap"
android:theme="#style/Theme.FullScreen" >
<!-- * Google Cloud Messaging -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<!-- Google Cloud Messaging * -->
<activity
android:name="com.magazine.screens.ShelfActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.magazine.screens.SplashActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.magazine.screens.ReaderActivity"
android:configChanges="keyboardHidden|screenSize"
android:windowSoftInputMode="adjustPan" >
</activity>
<activity
android:name="com.magazine.screens.PurchaseActivity"
android:configChanges="orientation"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.magazine.screens.FacebookActivity"
android:configChanges="orientation"
android:hardwareAccelerated="true"
android:icon="#drawable/fb_logo"
android:screenOrientation="portrait" >
</activity>
<!-- * Google Cloud Messaging -->
<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" />
<category android:name="com.was.abcd" />
</intent-filter>
</receiver>
<activity
android:name="com.magazine.messaging.NotificationDialogActivity"
android:configChanges="orientation"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" >
</activity>
<service
android:name="com.magazine.messaging.GcmIntentService"
android:exported="false" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
</intent-filter>
</service>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/app_id" />
<activity
android:name="com.facebook.LoginActivity"
android:label="#string/app_name" >
</activity>
</application>
Please take a look at these points:
As per Google Documentation make use of GCMReceiver instead of WakefulBroadcastReceiver.
Also if you are using gcm.register() please make us of InstanceId as the former has been deprecated.
Hope that helps!!
Got myself newly registered on AirPush. I integrated bundle SDK with my App. When I tested it for the first time, I got a couple of impressions. It also shows 2 impressions on dashboard.
Now I am unable to fetch the impressions. Did contact the developer team but to no avail.
My code of MainActivity goes like this :
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// MMSDK.initialize(this);
// setup a new adView and initialize an adRequest to it.
setupAirPushAdView();
}
#Override
public void onResume() {
super.onResume();
if ((getResources().getConfiguration().screenLayout
& Configuration.SCREENLAYOUT_SIZE_MASK)
== Configuration.SCREENLAYOUT_SIZE_SMALL) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
try {
if (!appStarted) {
setContentView(R.layout.main);
appStarted = true;
}
} catch (Exception e) {
Toast.makeText(this, e.getMessage() + "\n" + e.getClass().toString() + "\n" + e.getLocalizedMessage() + "\n", Toast.LENGTH_LONG).show();
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
perform();
}
}, 2000);
}
private void perform() {
setContentView(R.layout.app_home);
if (!appStarted) {
// attachAdView();
attachAirPushAdView();
appStarted = true;
}
...
Other Methods :
private void setupAirPushAdView() {
ma = new MA(this, null, false);
airPushAdView = new AdView(this, AdView.BANNER_TYPE_IN_APP_AD, AdView.PLACEMENT_TYPE_INTERSTITIAL, false, false,
AdView.ANIMATION_TYPE_LEFT_TO_RIGHT);
}
private void attachAirPushAdView() {
LinearLayout outerAdLayout = (LinearLayout) findViewById(R.id.externalAdId);
outerAdLayout.addView(airPushAdView);
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-sdk android:minSdkVersion="9"/>
<!-- android:theme="#android:style/Theme.DeviceDefault.Light" -->
<!-- android:theme="#android:style/Theme.Light.NoTitleBar.Fullscreen" -->
<application android:theme="#style/AppTheme" android:label="#string/app_name" android:icon="#drawable/ic_launcher">
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<activity android:name="MainActivity"
android:label="#string/app_name"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="differential_activity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor"
>
</activity>
<activity android:name="integral_activity"
android:screenOrientation="portrait"
>
</activity>
<activity android:name="equation_activity"
android:screenOrientation="portrait"
>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<!-- android:configChanges="keyboardHidden|orientation"
android:screenOrientation="nosensor" -->
<!-- for all activities -->
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.gyesa.keanp176500.APPID" android:value="206488" />
<meta-data android:name="com.gyesa.keanp176500.APIKEY" android:value="android*1392147786176500813"/>
<activity android:exported="false" android:name="com.gyesa.keanp176500.AdActivity"
android:configChanges="orientation|screenSize"
android:theme="#android:style/Theme.Translucent" />
<activity android:name="com.gyesa.keanp176500.BrowserActivity"
android:configChanges="orientation|screenSize" />
<activity android:name="com.gyesa.keanp176500.VActivity"
android:configChanges="orientation|screenSize" android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen" >
</activity>
<service android:name="com.gyesa.keanp176500.LService" android:exported="false"></service>
<receiver android:name="com.gyesa.keanp176500.BootReceiver" android:exported="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
<uses-feature android:name="android.hardware.microphone" android:required="false" />
</manifest>
I tried to update from the gcm.jar to get the GCM from the google-play-services.jar.
I'm using the same code as shown here.
I'm using the same server (node-gcm) as before the change of the client implementation.
I get the registrationId but when I tried to send a notification, GcmBroadcastReceiver.onReceive wasn't called. (I have it on the manifest file)
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;
/**
* Created with IntelliJ IDEA.
* User: Eran
* Date: 11/11/13
* Time: 00:43
* To change this template use File | Settings | File Templates.
*/
public class GcmBroadcastReceiver extends WakefulBroadcastReceiver {
#Override
public void onReceive(Context context, Intent intent) {
Log.d("GcmBroadcastReceiver", intent.getDataString());
// Explicitly specify that GcmIntentService will handle the intent.
ComponentName comp = new ComponentName(context.getPackageName(),
GcmIntentService.class.getName());
// Start the service, keeping the device awake while it is launching.
startWakefulService(context, (intent.setComponent(comp)));
setResultCode(Activity.RESULT_OK);
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gamerlabs.high5poker"
android:versionCode="3"
android:versionName="3.0">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
>
</supports-screens>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="com.android.vending.BILLING" />
<permission android:name="com.gameralabs.high5poker.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.gameralabs.high5poker.permission.C2D_MESSAGE" />
<application
android:name="com.gameralabs.classes.HFApplication"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true"
android:largeHeap="true"
android:debuggable="true"
>
<meta-data
android:name="com.facebook.sdk.ApplicationId"
android:value="#string/app_id" />
<activity android:name="com.facebook.LoginActivity"/>
<activity
android:name="com.gameralabs.high5poker.HFSplashActivity"
android:screenOrientation="landscape"
android:noHistory="true"
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="com.gameralabs.high5poker.HFLoginActivity"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
>
</activity>
<activity
android:name="com.gameralabs.high5poker.HFLobbyActivity"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
>
</activity>
<activity
android:name="com.gameralabs.high5poker.HFGameActivity"
android:noHistory="true"
android:screenOrientation="landscape"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
>
</activity>
<activity android:name="com.gameralabs.high5poker.HFActivity"/>
<receiver
android:name="com.gameralabs.high5poker.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.gameralabs.high5poker" />
</intent-filter>
</receiver>
<service android:name="com.gameralabs.high5poker.GcmIntentService" />
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
</application>
</manifest>
Any help?
You forgot to change the package name in the permissions.
<permission android:name="com.example.gcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.gcm.permission.C2D_MESSAGE" />
Should be
<permission android:name="com.mintmark.TestGcm.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.mintmark.TestGcm.permission.C2D_MESSAGE" />
Just a quick note that the new GCM implementation has been updated to state that we should remove the WakefulBroadcastReceiver from our code.
Per the new sample:
In the app manifest, replace your GcmBroadcastReceiver with
"com.google.android.gms.gcm.GcmReceiver", and replace the current
service declaration that extends IntentService to the new
GcmListenerService
Remove the BroadcastReceiver implementation from your client code
mRegistrationBroadcastReceiver = new BroadcastReceiver() {
#Override
public void onReceive(Context context, Intent intent) {
mRegistrationProgressBar.setVisibility(ProgressBar.GONE);
SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(context);
boolean sentToken = sharedPreferences
.getBoolean(QuickstartPreferences.SENT_TOKEN_TO_SERVER, false);
if (sentToken) {
mInformationTextView.setText(getString(R.string.gcm_send_message));
} else {
mInformationTextView.setText(getString(R.string.token_error_message));
}
}
};
#Override
protected void onResume() {
super.onResume();
LocalBroadcastManager.getInstance(this).registerReceiver(mRegistrationBroadcastReceiver,
new IntentFilter(QuickstartPreferences.REGISTRATION_COMPLETE));
}
#Override
protected void onPause() {
LocalBroadcastManager.getInstance(this).unregisterReceiver(mRegistrationBroadcastReceiver);
super.onPause();
}
I'm trying to create a launcher/homescreen. The application crashes on restart.
Debugger displays : "Unable to get provider mono.MonoRuntimeProvider". You have to wait a long time before the MonoRuntimeProvider is started, and then the app works. Any ideas to resolve this problem?
Activity1.cs
[Activity(Label = "Test application", MainLauncher = true, Icon = "#drawable/icon")]
public class Activity1 : Activity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
try
{
base.OnCreate(bundle);
RequestWindowFeature(WindowFeatures.NoTitle);
Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
}
catch (Exception ex)
{
Log.Error("TestError","Test Error:" + ex.Message);
}
//
}
Manifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="internalOnly" package="Test.AndroidMono" android:versionCode="1" android:versionName="test">
<application android:label="Test AndroidMono" >
<activity android:name="monoandroidapplication2.Activity1"
android:launchMode="singleInstance"
android:stateNotNeeded="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.CATEGORY_LAUNCHER" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.REBOOT" />
<uses-permission android:name="android.permission.DEVICE_POWER" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</manifest>
Find the solution:
MonoRuntimeProvider is required for debugging. Once I made a release, it worked perfectly...