フォーラム


ゲスト  

ようこそ ゲスト さん。このフォーラムに投稿するには 登録が必要です。

ページ: [1]
トピック: [Team Japan] Androidエミュレータ BlueStacks(ブルースタックス)上で FireMonkeyアプリを実行する
DEKO
管理者
投稿数: 2690
[Team Japan] Androidエミュレータ BlueStacks(ブルースタックス)上で FireMonkeyアプリを実行する
on: 2015/10/27 17:12 Tue

http://blogs.embarcadero.com/teamj/2015/10/27/4761/

[FMX.Platform.Android.pas]
function TWindowManager.RetrieveContentRect: TRect;
var
Activity: JActivity;
NativeWin: JWindow;
DecorView: JView;
ContentRectVisible, ContentRect: JRect;
begin
Activity := TAndroidHelper.Activity;
if Activity <> nil then
begin
NativeWin := Activity.getWindow;
if NativeWin <> nil then
begin
FStatusBarHeight := FNewContentRect.top;
ContentRect := TJRect.Create;
DecorView := NativeWin.getDecorView;
DecorView.getDrawingRect(ContentRect);

// add start
CallInUIThread(
procedure
begin
if (not PlatformAndroid.GetFullScreen(nil)) and
(SharedActivity.getWindow.getAttributes.flags and TJWindowManager_LayoutParams.JavaClass.FLAG_FULLSCREEN <>
TJWindowManager_LayoutParams.JavaClass.FLAG_FULLSCREEN) then
begin
ContentRectVisible := TJRect.Create;
DecorView.getWindowVisibleDisplayFrame(ContentRectVisible);
if (ContentRect.top < 1) or (ContentRectVisible.top < FStatusBarHeight) then
begin
ContentRect.top := ContentRectVisible.top;
FNewContentREct.top := ContentRectVisible.top;
FStatusBarHeight := FNewContentRect.top;
end;
end;
end
);
// add end

Result := TRect.Create(Round(FNewContentRect.left / FScale), Round(FNewContentRect.top / FScale),
Round(ContentRect.right / FScale), Round(ContentRect.bottom / FScale));
end;
end;
end;

 
この修正を行えば Android-x86 でも動作するようになるようです。

See Also:
[Acer Aspire One with Android-x86]
http://ht-deko.com/aspireone/

DEKO
管理者
投稿数: 2690
Androidエミュレータ BlueStacks(ブルースタックス)上で FireMonkeyアプリを実行する
on: 2017/01/12 17:56 Thu

Running Delphi Applications on Android Intel
http://community.embarcadero.com/blogs/entry/running-delphi-applications-on-android-intel
の記事で紹介されている手順で Androidエミュレータ BlueStacks に Delphiアプリを転送して実行してみます。

前準備として、Google USB Driverと BlueStacksのインストールが必要です。

Google USB Driver は、
http://developer.android.com/intl/ja/sdk/win-usb.html
または Android SDKマネージャから Google USB Driverをダウンロードしてインストールしておきます。

BlueStacksを Windows PC上にインストールするには、
http://www.bluestacks.com/ にアクセスしてインストーラをダウンロードし、PC上にインストールします。

Delphi を起動して、ボタンを押したらボタンの表示が変わるだけのアプリケーションを作成します。
[ファイル | 新規作成 | マルチデバイスアプリケーション - Delphi]
「空のアプリケーション」を選択します
ツールパレットから TButtonをフォーム上に置き、TButtonの onClickイベントで
Button1.Text := ‘Hello !’;
と記述しておきます。

FMX.Platform.Android.pas を自分のプロジェクトを保存しているフォルダにコピーします。
コピーした FMX.Platform.Android.pas を開き、function TWindowManager.RetrieveContentRect (おおよそ 1780行あたり)を
https://magnumlabs.wordpress.com/2015/10/10/delphiandroid-misalignment-status-bar-on-intel-based-devices/
に記載されているように修正します。

以下は 10 Seattle上で修正したコードです。(//addのところを追加しています)

function TWindowManager.RetrieveContentRect: TRect;
var
 Activity: JActivity;
 NativeWin: JWindow;
 DecorView: JView;
 ContentRectVisible, //add
 ContentRect: JRect;
begin
 Activity := TAndroidHelper.Activity;
 if Activity nil then
 begin
  NativeWin := Activity.getWindow;
  if NativeWin nil then
  begin
   FStatusBarHeight := FNewContentRect.top;
   ContentRect := TJRect.Create;
   DecorView := NativeWin.getDecorView;
   DecorView.getDrawingRect(ContentRect);

   // add start
   CallInUIThread(
    procedure begin
     if (not PlatformAndroid.GetFullScreen(nil)) and (SharedActivity.getWindow.getAttributes.flags
       and TJWindowManager_LayoutParams.JavaClass.FLAG_FULLSCREEN <> TJWindowManager_LayoutParams.JavaClass.FLAG_FULLSCREEN) then begin
      ContentRectVisible := TJRect.Create;
      DecorView.getWindowVisibleDisplayFrame(ContentRectVisible);
      if (ContentRect.top < 1) or (ContentRectVisible.top < FStatusBarHeight) then begin
       ContentRect.top := ContentRectVisible.top;
       FNewContentREct.top := ContentRectVisible.top;
       FStatusBarHeight := FNewContentRect.top;
      end;
     end;
    end
    );
// add end

   Result := TRect.Create(Round(FNewContentRect.left / FScale), Round(FNewContentRect.top / FScale),
   Round(ContentRect.right / FScale), Round(ContentRect.bottom / FScale));
  end;
 end;
end;

 
BlueStacksは起動しておきます。起動していると、プロジェクトマネージャ上で Androidを開きターゲットを確認すると
emulator-5554(5554) という名前で、BlueStacksが見えます。ダブルクリックして選択します。


実は、このまま実行してしまうと

のような表示が出て実行できません。

これを防ぐには、IDEのメニューから [プロジェクト | 配置]を選択して配置マネージャを表示します。
libnative-activity.so のチェックを外し、このファイルをデプロイ対象から外します。

この設定で実行すると、作成した FireMonkey アプリが BlueStacks上で動作します。

ページ: [1]
WP Forum Server by ForumPress | LucidCrew
バージョン: 1.7.5 ; ページロード: 0.034 sec.