Skip to content

Instantly share code, notes, and snippets.

<uses-feature android:name="android.hardware.sensor.stepcounter" />
<uses-feature android:name="android.hardware.sensor.stepdetector" />
@jamesmontemagno
jamesmontemagno / StepServiceBinder.cs
Last active August 29, 2015 13:59
Service binder and connection
using Android.OS;
namespace StepCounter.Services
{
public class StepServiceBinder : Binder
{
StepService stepService;
public StepServiceBinder (StepService service)
{
this.stepService = service;
@jamesmontemagno
jamesmontemagno / StepService.cs
Created April 17, 2014 06:32
StepService code with INotifyPropertyChanged
using System;
using Android.App;
using Android.Hardware;
using Android.Content;
using System.ComponentModel;
using StepCounter.Helpers;
using StepCounter.Database;
using StepCounter.Activities;
namespace StepCounter.Services
@jamesmontemagno
jamesmontemagno / MainActivity.cs
Created April 17, 2014 06:37
Example of binding my service!
using Android.App;
using Android.Content;
using Android.OS;
using Android.Widget;
using Android.Content.PM;
using System;
using StepCounter.Helpers;
using StepCounter.Controls;
using Android.Views.Animations;
using StepCounter.Services;
[BroadcastReceiver]
[IntentFilter(new []{"android.intent.action.BOOT_COMPLETED"})]
public class BootReceiver : BroadcastReceiver
{
public override void OnReceive (Context context, Intent intent)
{
var stepServiceIntent = new Intent(context, typeof(StepService));
context.StartService(stepServiceIntent);
}
}
@jamesmontemagno
jamesmontemagno / styles.xml
Created April 17, 2014 06:47
Transparent ActionBar
<!-- Application theme. -->
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/MyTheme.ActionBar</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/red_background</item>
</style>
<style name="MyTheme.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">@android:color/transparent</item>
<item name="android:backgroundStacked">@android:color/transparent</item>
using System;
#if __ANDROID__
using Android.Graphics;
#elif __IOS__
using MonoTouch.UIKit;
using Color = MonoTouch.UIKit.UIColor;
#endif
#if __ANDROID__
<?xml version="1.0" encoding="utf-8"?>
<stepcounter.controls.ProgressView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/progressView">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/blue_background"
android:id="@+id/top_layer"
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/MyTheme.ActionBar</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/red_background</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
</style>
<FrameLayout
android:fitsSystemWindows="true"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<TextView
android:text="@string/calories"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"