I tried to add a BroadcastReciever to the Android part of my Xamarin app to help with notifications, but if I try to register it in the manifest, I get the build error in the title of this question. I don't want to use code attributes because then it won't work if the app isn't running according to Microsoft's documentation (I don't remember which page).
Here is my (unmerged) manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.partylist" android:installLocation="auto">
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<application android:label="Partylist.Android">
<reciever android:name=".AlarmReciever" android:enabled="false">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</reciever>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECIEVE_BOOT_COMPLETED" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
</manifest>
Also, the line that the error says it's on is actually the line where I have the intent filter inside the BroadcastReciever, not the BroadcastReciever itself.
Watch out for spelling typos, It should be <receiver> from BroadcastReceiver.
Related
I change the manifest file to use the following theme:
change from:
#style/AppTheme
to
#style/Theme.Material.Light
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="App1.App1" android:installLocation="preferExternal">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="27" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:allowBackup="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:roundIcon="#mipmap/ic_launcher_round" android:supportsRtl="true" **android:theme="#style/Theme.Material.Light"></application>
</manifest>
But when building and deploying got the following error:
Sdkminversion is as follows it is above 21.
uses-sdk android:minSdkVersion="23"
i have managed to make it able to compile using Theme.Holo.Light
however,the theme is still black in color by clearing the content in the following folder:
C:\Users\your_name\AppData\Local\Xamarin
Theme.Holo.Light is supposed to be white in colour background ,right?
Any idea what is wrong?
You should define Theme.Material.Light in your /Resource/values/style.xml.
<style name="MyMaterialTheme" parent="Theme.Material.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="colorPrimary">#1286d9</item>
<item name="colorPrimaryDark">#1286d9</item>
</style>
& than use it like this #style/MyMaterialTheme. You should use color and other features according to your preference.
😊
I am trying to implement GCM without BAAS in GCM. I have looked at previous examples using the bridge and from my research the following should work without relying on the old TGCMReceiver component.
But the following line always returns nil, I run this after the application starts up on a button click:
APushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.GCM);
APushService is always nil.
My AndroidManifest looks as follows:
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.embarcadero.Project1"
android:versionCode="1"
android:versionName="1.0.0"
android:installLocation="auto">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<permission android:name="com.embarcadero.Project1.permission.C2D_MESSAGE" android:protectionLevel="signature" />
<uses-permission android:name="com.embarcadero.Project1.permission.C2D_MESSAGE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
<application android:persistent="False"
android:restoreAnyVersion="False"
android:label="Project1"
android:debuggable="True"
android:largeHeap="False"
android:icon="#drawable/ic_launcher"
android:theme="#style/AppTheme"
android:hardwareAccelerated="true">
<meta-data android:name="com.google.android.gms.version" android:value="4323000" />
<!-- Our activity is a subclass of the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
android:label="Project1"
android:configChanges="orientation|keyboard|keyboardHidden|screenSize"
android:launchMode="singleTask">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="Project1" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
<receiver
android:name="com.embarcadero.gcm.notifications.GCMNotification" 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.embarcadero.Project1" />
</intent-filter>
</receiver>
<receiver android:name="com.embarcadero.rtl.notifications.NotificationAlarm" />
<receiver android:exported="true" android:name="com.embarcadero.gcm.notifications.GCMNotification" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<category android:name="com.embarcadero.Project1" />
</intent-filter>
</receiver>
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
I have tried using the common TGCMReceiver application that is out there from CodeRage9 using XE8, it doesn't work in XE10 / Seattle and it does appear that XE10 is updated in this regard but I cannot make anything work with simple Google Cloud Messaging and am looking for some guidance.
The answer is shown here: Issue with GCM Push notification service DELPHI XE6
Except with .Active := True not AutoActivate := True as indicated by the Answer.
TL;DR version. Drop TKinvyProvider on form with just the GCMAppID populated, Drop TPushEvent on Form with AutoRegister and AutoActivate set to false. In entitlement list set "support push notification : true".. add in the following to your AndroidManifest.template.xml:
<service android:name="com.embarcadero.gcm.notifications.GCMIntentService" />
Right before </application>.
I know its a repost but none of the answers that I found on other posts did not work for me, and I do not get why.
This is my permisions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.LOCATION_HARDWARE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="nl.hgrams.passenger.C2D_MESSAGE" />
And this is my main activity:
<activity
android:name=".activities.PSTimelineActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustNothing"
android:launchMode="singleTop"
android:label="#string/passenger_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="psngr://" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
Now when I enter the site: psngr.co/applauncher, this page redirects to a page "psnr://" which shows a "Website not available". Shouldn't this url start my app?
Instead of :
<data android:scheme="psngr://" />
I used just:
<data android:scheme="psngr" />
Now it works, honest mistake.
Push Notifications for my Android app using Trigger.io and Parse are not working. Everything seems to be set up correctly in Parse and Trigger, Parse says the pushes are going through but the phone never receives them regardless if the app is open or not. I have another part of the app that successfully uploads photos to Parse and uses the REST API to pull them back down and I see my single installation in the dashboard assigned to my beta channel. Neither the Broadcast nor the specific channel seems to work. I'm just wondering if there is a setting on the device or in my config file that I need to switch to allow the push notifications to go through. All documentation I can find still references the forge.partners.parse functions which are no longer in use and the syntax seems to be a bit different around this functionality now. Any help is appreciated!!
I found something that could be a factor, my AndroidManifest seems to be missing a couple things that are show on the Parse documentation(here: https://parse.com/tutorials/android-push-notifications ), I can't directly edit this XML file because Trigger compiles it automatically so I'm not sure what I can do.
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="io.trigger.forge44c192547c6611e3b1811231392b77b0" android:installLocation="auto" android:versionCode="1391094815" android:versionName="0.1">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="15" />
<application android:icon="#drawable/icon" android:label="TheFireStore App" android:name="io.trigger.forge.android.core.ForgeApp">
<activity android:configChanges="mcc|mnc|locale|touchscreen|keyboardHidden|navigation|orientation|screenLayout|uiMode|fontScale|screenSize" android:launchMode="singleTask" android:name="io.trigger.forge.android.core.ForgeActivity" android:stateNotNeeded="true" android:theme="#android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="TheFireStore.com" />
</intent-filter>
</activity>
<provider android:authorities="io.trigger.forge44c192547c6611e3b1811231392b77b0" android:exported="true" android:name="io.trigger.forge.android.core.ForgeContentProvider" tools:ignore="ExportedContentProvider" />
<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>
</application>
<uses-permission android:name="android.permission.ACCESS_GPS" />
<uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" />
<uses-permission android:name="android.permission.ACCESS_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />
I'm trying to add Google Maps v2 to an Mvx project by combining the Monodroid MapsAndLocationDemo_v2 with the N=26 Fraggle demo from NPlus1DaysOfMvvmCross.
I have added Google Play services to the Maps demo and am successfully displaying a map using:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment" />
With the Fraggle demo, the same fragment causes an Android.Views.InflateException error.
I have followed the same steps to add Google Play services to both projects, and am using the same AndroidManifest.xml file in both projects
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.demo.app" android:installLocation="auto" android:versionCode="1" android:versionName="1">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application android:label="Demo"></application>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<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.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="com.demo.app.permission.MAPS_RECEIVE" />
<permission android:name="com.demo.app.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AAAAAAAAAAAAAAAAA-xxxxxxxxxxxxxxxxxxxxxx" />
</manifest>
Other than adding the fragment and updating the manifest, there are no changes to the Fraggle demo code. The working view from the Maps demo is
namespace SimpleMapDemo
{
using Android.App;
using Android.OS;
using Android.Support.V4.App;
[Activity(Label = "#string/basic_map")]
public class BasicDemoActivity : FragmentActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.BasicDemo);
}
}
}
and the view from the Mvx version is:
using Android.App;
using Android.OS;
using Cirrious.MvvmCross.Droid.Fragging;
using Rock.Core.ViewModels;
namespace Rock.Droid.Views
{
[Activity(Label = "View for FirstViewModel")]
public class FirstView : MvxFragmentActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.FirstView);
}
}
}
I've also tried referencing the Google Play services dll from the working demo, and have the same results.
Ah. It was a mistake in the AndroidManifest.xml file. The Maps API Key needs to be inside the application node. If it's not there, it causes an exception.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.demo.app" android:installLocation="auto" android:versionCode="1" android:versionName="1">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" />
<application android:label="Demo">
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AAAAAAAAAAAAAAAAA-xxxxxxxxxxxxxxxxxxxxxx" />
</application>
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
<uses-permission android:name="android.permission.INTERNET" />
<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.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="com.demo.app.permission.MAPS_RECEIVE" />
<permission android:name="com.demo.app.permission.MAPS_RECEIVE" android:protectionLevel="signature" />
</manifest>