diff --git a/README.md b/README.md index 1a0860be807..4a878fac8fd 100644 --- a/README.md +++ b/README.md @@ -178,17 +178,37 @@ For example, to generate `Mono.Android.dll` for API-19 (Android 4.4): xbuild /p:AndroidApiLevel=19 /p:AndroidFrameworkVersion=v4.4 # creates bin\Debug\lib\xbuild-frameworks\MonoAndroid\v4.4\Mono.Android.dll -## Contributing ## +# Samples -### Mailing Lists +The [HelloWorld](samples/HelloWorld) sample may be built with the +[xabuild](tools/scripts/xabuild) script: + + $ tools/scripts/xabuild /t:SignAndroidPackage samples/HelloWorld/HelloWorld.csproj + +`xabuild /t:SignAndroidPackage` will generate an `.apk` file, which may be +installed onto an Android device with the [`adb install`][adb-commands] +command: + +[adb-commands]: http://developer.android.com/tools/help/adb.html#commandsummary + + $ adb install samples/HelloWorld/bin/Debug/com.xamarin.android.helloworld-Signed.apk + +**HelloWorld** may be launched manually through the Android app launcher, +or via `adb shell am`: + + $ adb shell am start com.xamarin.android.helloworld/example.MainActivity + +# Contributing + +## Mailing Lists To discuss this project, and participate in the design, we use the [android-devel@lists.xamarin.com](http://lists.xamarin.com/mailman/listinfo/android-devel) mailing list. -### Coding Guidelines +## Coding Guidelines We use [Mono's Coding Guidelines](http://www.mono-project.com/community/contributing/coding-guidelines/). -### Reporting Bugs +## Reporting Bugs We use [Bugzilla](https://bugzilla.xamarin.com/enter_bug.cgi?product=Android) to track issues. diff --git a/Xamarin.Android.sln b/Xamarin.Android.sln index 61e90e49b20..64ba505ad12 100644 --- a/Xamarin.Android.sln +++ b/Xamarin.Android.sln @@ -53,6 +53,10 @@ Project("{9344BDBB-3E7F-41FC-A0DD-8665D75EE146}") = "monodroid", "src\monodroid\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "api-xml-adjuster", "tools\api-xml-adjuster\api-xml-adjuster.csproj", "{8A6CB07C-E493-4A4F-AB94-038645A27118}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{99CBCF85-E4EB-41C8-9089-1A2B740681F0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "samples\HelloWorld\HelloWorld.csproj", "{2305B00D-DE81-4744-B0DA-357835CAFE5A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|AnyCPU = Debug|AnyCPU @@ -194,6 +198,18 @@ Global {E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU {E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU {E8492EFB-D14A-4F32-AA28-88848322ECEA}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.Debug|AnyCPU.ActiveCfg = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.Debug|AnyCPU.Build.0 = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.Release|AnyCPU.ActiveCfg = Release|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.Release|AnyCPU.Build.0 = Release|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationDebug|Any CPU.ActiveCfg = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationDebug|Any CPU.Build.0 = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationRelease|Any CPU.ActiveCfg = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationRelease|Any CPU.Build.0 = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationDebug|AnyCPU.ActiveCfg = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationDebug|AnyCPU.Build.0 = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationRelease|AnyCPU.ActiveCfg = Debug|Any CPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A}.XAIntegrationRelease|AnyCPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {8FF78EB6-6FC8-46A7-8A15-EBBA9045C5FA} = {E351F97D-EA4F-4E7F-AAA0-8EBB1F2A4A62} @@ -219,6 +235,7 @@ Global {D48EE8D0-0A0A-4493-AEF5-DAF5F8CF86AD} = {864062D3-A415-4A6F-9324-5820237BA058} {53EE4C57-1C03-405A-8243-8DA539546C88} = {04E3E11E-B47D-4599-8AFC-50515A95E715} {8A6CB07C-E493-4A4F-AB94-038645A27118} = {864062D3-A415-4A6F-9324-5820237BA058} + {2305B00D-DE81-4744-B0DA-357835CAFE5A} = {99CBCF85-E4EB-41C8-9089-1A2B740681F0} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0 diff --git a/samples/HelloWorld/Assets/AboutAssets.txt b/samples/HelloWorld/Assets/AboutAssets.txt new file mode 100644 index 00000000000..a9b0638eb1b --- /dev/null +++ b/samples/HelloWorld/Assets/AboutAssets.txt @@ -0,0 +1,19 @@ +Any raw assets you want to be deployed with your application can be placed in +this directory (and child directories) and given a Build Action of "AndroidAsset". + +These files will be deployed with your package and will be accessible using Android's +AssetManager, like this: + +public class ReadAsset : Activity +{ + protected override void OnCreate (Bundle bundle) + { + base.OnCreate (bundle); + + InputStream input = Assets.Open ("my_asset.txt"); + } +} + +Additionally, some Android functions will automatically load asset files: + +Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); diff --git a/samples/HelloWorld/HelloWorld.csproj b/samples/HelloWorld/HelloWorld.csproj new file mode 100644 index 00000000000..46afc92b756 --- /dev/null +++ b/samples/HelloWorld/HelloWorld.csproj @@ -0,0 +1,68 @@ + + + + Debug + AnyCPU + {2305B00D-DE81-4744-B0DA-357835CAFE5A} + {EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + HelloWorld + HelloWorld + v5.0 + True + Resources\Resource.designer.cs + Resource + Properties\AndroidManifest.xml + Resources + Assets + true + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + None + + + true + bin\Release + prompt + 4 + false + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/HelloWorld/MainActivity.cs b/samples/HelloWorld/MainActivity.cs new file mode 100644 index 00000000000..43d1421ef7f --- /dev/null +++ b/samples/HelloWorld/MainActivity.cs @@ -0,0 +1,34 @@ +using Android.App; +using Android.Widget; +using Android.OS; + +namespace HelloWorld +{ + [Activity ( + Icon = "@mipmap/icon", + Label = "HelloWorld", + MainLauncher = true, + Name = "example.MainActivity")] + public class MainActivity : Activity + { + int count = 1; + + protected override void OnCreate (Bundle savedInstanceState) + { + base.OnCreate (savedInstanceState); + + // Set our view from the "main" layout resource + SetContentView (Resource.Layout.Main); + + // Get our button from the layout resource, + // and attach an event to it + Button button = FindViewById