turn Raylib-cs.Android
into android library
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<application android:allowBackup="true" android:icon="@mipmap/appicon"
|
||||
android:label="@string/app_name" android:roundIcon="@mipmap/appicon_round"
|
||||
android:supportsRtl="true">
|
||||
</application>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
</manifest>
|
@@ -1 +0,0 @@
|
||||
[assembly: UsesFeature(GLESVersion = 0x00020000, Required = true)]
|
@@ -1,42 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using Android.Content;
|
||||
using Android.Content.PM;
|
||||
|
||||
namespace Raylib_cs.Android;
|
||||
|
||||
[
|
||||
Activity(
|
||||
Label = "@string/app_name",
|
||||
MainLauncher = true,
|
||||
ConfigurationChanges = ConfigChanges.Orientation
|
||||
| ConfigChanges.KeyboardHidden
|
||||
| ConfigChanges.ScreenSize,
|
||||
ScreenOrientation = ScreenOrientation.Landscape,
|
||||
ClearTaskOnLaunch = true
|
||||
),
|
||||
IntentFilter(new[] { Intent.ActionMain }),
|
||||
MetaData(NativeActivity.MetaDataLibName, Value = "raylib")
|
||||
]
|
||||
public class MainActivity : NativeActivity
|
||||
{
|
||||
static MainActivity()
|
||||
{
|
||||
RaylibSetAndroidCallback(Main);
|
||||
}
|
||||
|
||||
private static void Main()
|
||||
{
|
||||
Raylib.InitWindow(0, 0, "android_window");
|
||||
while (!Raylib.WindowShouldClose())
|
||||
{
|
||||
Raylib.BeginDrawing();
|
||||
Raylib.ClearBackground(Color.WHITE);
|
||||
Raylib.DrawFPS(10, 10);
|
||||
Raylib.DrawText("Hello Raylib-cs.Android", 20, 100, 100, Color.BLACK);
|
||||
Raylib.EndDrawing();
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("raylib")]
|
||||
private static extern void RaylibSetAndroidCallback(Action callback);
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
```sh
|
||||
# clear nuget local cache if you install raylib-cs from nuget before
|
||||
dotnet nuget locals all --clear
|
||||
|
||||
# install android sdk requirements
|
||||
# or just install it from visual studio
|
||||
sdkmanager "build-tools;34.0.0" "ndk;25.2.9519653" "platforms;android-34"
|
||||
|
||||
# install android workload
|
||||
dotnet workload install android
|
||||
|
||||
# download artifact.zip from https://github.com/anggape/Raylib-cs/actions/runs/5630394074 and extract it
|
||||
dotnet restore --source <path to extracted artifact.zip>
|
||||
|
||||
# connect your android device or create new emulator
|
||||
adb devices # make sure your device there
|
||||
|
||||
# run project
|
||||
dotnet run
|
||||
```
|
@@ -1,16 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0-android</TargetFramework>
|
||||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
|
||||
<RootNamespace>Raylib_cs.Android</RootNamespace>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<ApplicationId>com.companyname.Raylib_cs.Android</ApplicationId>
|
||||
<ApplicationVersion>1</ApplicationVersion>
|
||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||
<AssemblyName>Raylibcs.Android</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Raylib-cs" Version="4.5.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
17
Raylib-cs.Android/RaylibActivity.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Raylib_cs;
|
||||
|
||||
public abstract class RaylibActivity : NativeActivity
|
||||
{
|
||||
protected override void OnCreate(Bundle? savedInstanceState)
|
||||
{
|
||||
base.OnCreate(savedInstanceState);
|
||||
RaylibSetAndroidCallback(OnReady);
|
||||
}
|
||||
|
||||
protected abstract void OnReady();
|
||||
|
||||
[DllImport("raylib")]
|
||||
private static extern void RaylibSetAndroidCallback(Action callback);
|
||||
}
|
@@ -1,44 +0,0 @@
|
||||
Images, layout descriptions, binary blobs and string dictionaries can be included
|
||||
in your application as resource files. Various Android APIs are designed to
|
||||
operate on the resource IDs instead of dealing with images, strings or binary blobs
|
||||
directly.
|
||||
|
||||
For example, a sample Android app that contains a user interface layout (main.xml),
|
||||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png)
|
||||
would keep its resources in the "Resources" directory of the application:
|
||||
|
||||
Resources/
|
||||
drawable/
|
||||
icon.png
|
||||
|
||||
layout/
|
||||
main.xml
|
||||
|
||||
values/
|
||||
strings.xml
|
||||
|
||||
In order to get the build system to recognize Android resources, set the build action to
|
||||
"AndroidResource". The native Android APIs do not operate directly with filenames, but
|
||||
instead operate on resource IDs. When you compile an Android application that uses resources,
|
||||
the build system will package the resources for distribution and generate a class called "Resource"
|
||||
(this is an Android convention) that contains the tokens for each one of the resources
|
||||
included. For example, for the above Resources layout, this is what the Resource class would expose:
|
||||
|
||||
public class Resource {
|
||||
public class Drawable {
|
||||
public const int icon = 0x123;
|
||||
}
|
||||
|
||||
public class Layout {
|
||||
public const int main = 0x456;
|
||||
}
|
||||
|
||||
public class Strings {
|
||||
public const int first_string = 0xabc;
|
||||
public const int second_string = 0xbcd;
|
||||
}
|
||||
}
|
||||
|
||||
You would then use Resource.Drawable.icon to reference the drawable/icon.png file, or
|
||||
Resource.Layout.main to reference the layout/main.xml file, or Resource.Strings.first_string
|
||||
to reference the first string in the dictionary file values/strings.xml.
|
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@string/app_text"
|
||||
/>
|
||||
</RelativeLayout>
|
@@ -1,4 +0,0 @@
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@mipmap/appicon_background" />
|
||||
<foreground android:drawable="@mipmap/appicon_foreground" />
|
||||
</adaptive-icon>
|
@@ -1,4 +0,0 @@
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@mipmap/appicon_background" />
|
||||
<foreground android:drawable="@mipmap/appicon_foreground" />
|
||||
</adaptive-icon>
|
Before Width: | Height: | Size: 688 B |
Before Width: | Height: | Size: 97 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 604 B |
Before Width: | Height: | Size: 92 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 830 B |
Before Width: | Height: | Size: 100 B |
Before Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 978 B |
Before Width: | Height: | Size: 108 B |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 117 B |
Before Width: | Height: | Size: 2.7 KiB |
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="ic_launcher_background">#2C3E50</color>
|
||||
</resources>
|
@@ -1,4 +0,0 @@
|
||||
<resources>
|
||||
<string name="app_name">Raylib_cs.Android</string>
|
||||
<string name="app_text">Hello, Android!</string>
|
||||
</resources>
|