LoginSignup
2
3

More than 5 years have passed since last update.

システム アプリケーションとして Xamarin.Android をインストール

Last updated at Posted at 2016-08-17

■ 手順

0. Root化した端末を用意

1. "/bin/Release/*.apk" を解凍

2. 解凍先の "/lib/armeabi-v7a/*.so" にあるファイルを端末の "/system/lib/" にコピー

3. "/bin/Release/*.apk" を端末の "/system/priv-app/" にコピー

4. 端末の再起動

5. アプリを実行

■ 実験に使用したコード

▼ 追加権限

<uses-permission android:name="android.permission.MANAGE_USB" />

▼ ソースコード

var usbManager = (Android.Hardware.Usb.UsbManager)GetSystemService("usb");

var methods = usbManager.Class.GetDeclaredMethods();

for (int i = 0; i < methods.Length; i++)
{                
    if (methods[i].Name.Equals("setCurrentFunction"))
    {
        methods[i].Accessible = true;

        try
        {
            // USB でパソコンに接続するときの設定を MTP に変更
            methods[i].Invoke(usbManager, new Java.Lang.String("mtp"), true);

            Toast.MakeText(this, methods[i].Name, ToastLength.Long).Show();
        }
        catch(Java.Lang.Reflect.InvocationTargetException e)
        {
            Toast.MakeText(this, e.Cause.Message, ToastLength.Long).Show();
        }
    }
}

参考:
Installing Xamarin.Android as a System App
https://developer.xamarin.com/guides/android/advanced_topics/install-system-app/

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3