2020-04-01から1ヶ月間の記事一覧

バッチファイル内で別ファイルからバージョン番号を取得して変数として使用する

概要 バッチファイル内で使用する変数として、別ファイル内に書かれているバージョン番号を取得して使用する。 以下ではAndroidアプリ開発で使用するbuild.gradleファイル内からバージョン番号を取得する。 build.gradleファイル 以下のversionName "1.0.0"…

Xamarin: HTTP GETリクエスト

概要 XamarinでSystem.Net.Http.HttpClientを使用してHTTPのGETリクエストを行う。 docs.microsoft.com サンプルコード static readonly HttpClient client = new HttpClient(); // A) async void OnButtonClicked(System.Object sender, System.EventArgs e…

Xamarin: ファイル読み書き

概要 ファイルの読み書きを行う。 サンプルコード System.IO.Fileクラスを使用する。 public MainPage() { InitializeComponent(); // サンプルファイルパスの取得 String documentDir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);…

How to deal with out of memory problem while create thumbnail by PDFKit

iOS

Summary PDFKit has a method thumbnailOfSize: for create thumbnail but when you create thumbnail of all page by this method, memory consumption is increasing and it's cause of app crash. Solution You have to release PDFDocument instance tha…

Add any files in your iOS application bundle and use it in the app.

iOS

Outline You can add any files in your iOS application at build phase and use it in the app. Add files Add any files to your Xcode project. The following example add text file sample.txt. When you add files to the Xcode project, Xcode add t…

iOS版PDFKitでメモリ消費を押さえながらサムネイルを生成する

iOS

概要 iOS版PDFKitではPDFPageクラスにサムネイル生成用のメソッドthumbnailOfSize:が用意されている。このメソッドを使用して全ページのサムネイル画像を生成していくと、PDFによってはメモリ消費量がどんどん増加していき、アプリがクラッシュする。 解決策…

iOSアプリ内に埋め込んだファイルをプログラムから利用する

iOS

概要 アプリ内に任意のファイルを埋め込んでおき、プログラムからそのファイルにアクセスして利用する。 ファイルの追加 Xcodeプロジェクト内にファイルを追加する。以下ではテキストファイルsample.txtを追加している。 ファイルを追加すると、自動的にプロ…

Xamarin: 無料のAppleアカウントで実機iOSデバイスにアプリをインストールする

概要 Apple Developer Program(年間11,800円)に登録せずに無料のAppleアカウントで実機のiOSデバイスにアプリをインストールする。 手順 Xamarinプロジェクトを作成する。 通常通り、Xamarinプロジェクトを作成します。以下ではアプリケーションIDがcom.comp…

Xamarin: ログ出力

概要 XamarinのiOS, Androidアプリでログ出力する方法。 OS共通のAPI デバッグ用ビルドの場合のみ出力するAPI。 System.Diagnostics.Debug.WriteLine("System.Diagnostics.Debug.WriteLine"); デバッグ用とリリース用ビルドで出力するAPI。 System.Diagnosti…

Xamarin: ファイルパスの取得

概要 iOS, Androidのシステムディレクトリを取得する。 iOS, Android共通のAPI Xamarin.Essentials.FileSystem及びSystem.Environment.SpecialFolderを使用することができる。 サンプルコード System.Console.WriteLine("FileSystem.CacheDirectory=" + File…

Xamarin: JSONのエンコード、デコード

概要 XamarinでJSONのエンコード、デコードを行う。 依存関係 NuGetでSystem.Text.JSONを追加する必要があります。 *System.Text.JSONについては以下に説明があります。 docs.microsoft.com サンプルコード public MainPage() { InitializeComponent(); Stri…

Xamarin: プロジェクト内のリソースファイルを読み込む

概要 プロジェクト内に任意のファイルを配置し、それをアプリ内で読み込んで使用する。 プロジェクト内に任意のファイルを追加 プロジェクト内に任意のファイルを追加する。 *以下ではSampleText.txtを追加している。 追加したファイルのプロパティを開き、…

Amazon RDS: How to resolve problem that slow query log is stop on the Cloud Watch

AWS

Problem Amazon RDS can output slow query log to Cloud Watch. The cause is unclear but this log is sometimes stop. You can check log is working correctly by SQL below. select sleep(5); *The argument value of the sleep function (5 in above e…

Amazon RDS: スロークエリのログが出力されなくなった時の対応方法

AWS

症状 Amazon RDSではCloud Watchにスロークエリのログを出力することができる。 原因は分からないが、このスロークエリのログが出力されなくなってしまう場合がある。スロークエリが正常に出力されているかどうかは、以下のSQLを実行して確認できる。 select…

How to detect Chrome on iOS by JavaScript when "Request Desktop Site" setting is enabled.

Problem When the setting of "Request Desktop Site" of Chrome on iPhone is enabled, navigator value is changed that not include text CriOS. So you cannot detect browser is Chrome by JavaScript. *This problem and solution is checked on Chrom…

iOS版Chromeで「PC版サイトを見る」を有効にしている場合にJavaScriptでChromeであることを検知する

問題 iPhone版Chromeでは設定で「PC版サイトを見る」を有効にした場合、navigatorで取得できる情報が変化し、CriOSが含まれなくなるのでChromeであることが分からなくなる。 *Chrome 80.0.3987.95で確認。 iPhoneで取得可能なユーザーエージェント iPhone版C…

SQLite3: How to know transaction is already started

You can use get_autocommit() to know transaction is already started or not. When transaction is started: This function return 0 because auto-commit is disabled. When transaction is not started: This function return non-0 because auto-commi…

SQLite3: トランザクションが開始されているかどうかを判断する

現在SQLite3のトランザクションが開始されているかどうかを判断するには、get_autocommit()を使用する。 トランザクションが開始されている場合: 自動コミットが無効になるので0が返る。 トランザクションが開始されていない場合: 自動コミットが有効になる…