Delphi XE5 for Android Launcher no black screen wait summary

Source: Internet
Author: User
Tags exit in

Delphi XE5 for Android Launcher no black screen wait summary

from Embarcadero Official Technology forum to find the next reference, on the black screen processing should have a corresponding method, and this method has a good application value, so did a summary, Delphi XE5 No black screen is essentially the use of Android native development language Java, the program was written to start loading the Java-written splashscreen activity, Then start the com.embarcadero.firemonkey.FMXNativeActivity in the Splashscreenactivity in Delphi Firemonkey;

Start with a new mobile project, launch Rad Studio Xe5,file, new->firemonkey Mobile application, drag the previous Tlabel control as a demonstration, save the project

Set Android SDK I use the Android SDK 22.0.5 32bit version, the corresponding platform is 2.35, if you are other SDK version, you can right click on the SDK, select the Edit SDK to configure

Build the current project and open the current project under the AndroidManifest.template.xml file

Will be android:largeheap= "%largeheap%" removed, or the conference error (I am not sure whether the features of the Android version of the problem, or have no other parameters to set up, anyway, I just solved), OK, the demo first put here, We will then build a Java for Android startup activity project, which needs to be developed with Eclipse + ADT

Build Android Application Project, build Android Activity, name splashactivity, note the package namespace, my namespace is Com.cikk.splashsceen, Simply set the view

Next write Splashactivity code, we have to do is splashactivity start delay after 3 seconds, 3 seconds after the end of the start com.embarcadero.firemonkey.FMXNativeActivity this Delphi Xe5 for Android under this specific activity, the code is as follows

Package Com.cikk.splashsceen;

import Android.os.Bundle;

import android.app.Activity;

import android.content.Intent;

import Android.util.Log;

import Android.view.Window;

import Android.view.WindowManager;

Public class Splashactivity extendsActivity {

Private Boolean active = true;

Private Static int splash_time_out = 3000;

Private Static int splash_interval = 100;

int get_resource_id (string resourcename, String resourcetype)

{

return this. getresources (). Getidentifier (resourcename, ResourceType,

this. getpackagename ());

}

int get_string_id (string resourcename)

{

return get_resource_id (resourcename, "string");

}

int get_drawable_id (String resourcename)

{

return get_resource_id (resourcename, "drawable");

}

int get_layout_id (String resourcename)

{

return get_resource_id (resourcename, "layout");

}

@Override

Public void onCreate (Bundle savedinstancestate) {

Super. OnCreate (savedinstancestate);

Requestwindowfeature (Window. Feature_no_title);

GetWindow (). Addflags (Windowmanager.layoutparams. Flag_fullscreen);

Setcontentview (get_layout_id ("splash_activity"));

New Thread (new Runnable ()

{

@Override

Public void Run () {

Try

{

int elapsed = 0;

while (Splashactivity. this. Active && (Elapsed <splash_time_out))

{

Thread. Sleep (splash_interval);

if (Splashactivity. this. Active)

Elapsed + = Splash_interval;

}

}

Catch (Interruptedexception e)

{

}

Finally

{

Finish ();

if (Splashactivity. this. Active)

{

Intent launchintent = new Intent ();

Log. D ("Splash", "launching the main activity now");

Launchintent.setclassname (splashactivity. this, "com.embarcadero.firemonkey.FMXNativeActivity");

StartActivity (launchintent);

}

}

}

}). Start ();

}

}

Start debugging, and you'll automatically exit in three seconds.

Back to Delphi XE5, we'll build the SplashScreen project once and click Project->deployment to enter the Release Management module

Click Deploy Publish once, then open the project directory into the android\debug\splashscreen\classes subdirectory, you can see the Classes.dex file, this is the Delphi Firemonkey on Android Base Support library in Dalvik, Next, I'm going to use some tools to help me incorporate Java-written activity into Classes.dex;

Copy the SRC and res from the Java project to the splashscreeN project Directory of Delphi Xe5, and don't copy the wrong location.

Configure the system environment variables first

1. Android my is C:\Users\cikk\android-sdks

2. Configure the System Path

Build-tools: Mine is%android%\build-tools\19.0.0.

3. Check that the bin directory of the JDK is in system Path, it is recommended to use jdk1.6, I used 1.7, but because of the version problem, can not be successfully merged into the Classes.dex;

After configuration, open the Command Prompt window to run javac;jar;dx ensure the command can execute correctly;

BUILD.bat batch is written in the splashscreeN project directory of Delphi Xe5

The batch content is as follows

@echo on

Setlocal

Set android_platform= "%android%\platforms\android-10"

Set dx_lib= "%android%\build-tools\19.0.0\lib"

Set proj_dir= "?%"

Set embo_dex= "D:\Program Files\embarcadero\rad studio\12.0\lib\android\debug\classes.dex"

Set verbose=0

mkdir output\classes 2> nul

mkdir Output\jar 2> nul

mkdir Output\dex 2> nul

Echo.

echo Compile Java splashactivity.java source file

Echo.

SET Verbose_flag=-verbose

Javac%verbose_flag%-xlint:deprecation-cp%android_platform%\android.jar-d output\classes src\com\cikk\splashsceen \splashactivity.java

Echo.

ECHO Create Jar Package

Echo.

SET Verbose_flag=v

Jar c%verbose_flag%f output\jar\test_classes.jar-c output\classes com

Echo.

Echo converted to DEX format

Echo.

SET Verbose_flag=--verbose

Call DX--dex%verbose_flag%--output=%proj_dir%\output\dex\test_classes.dex--positions=lines%PROJ_DIR%\output\jar \test_classes.jar

Echo.

Echo Merge Dex file

Echo.

JAVA-CP%dx_lib%\dx.jar Com.android.dx.merge.DexMerger%proj_dir%\output\dex\classes.dex%proj_dir%\output\dex\ Test_classes.dex%embo_dex%

Echo Delete temp file

Echo.

Del Output\dex\test_classes.dex

Del Output\jar\test_classes.jar

RmDir Output\jar

Echo.

echo Output is Output\dex\classes.dex

: Exit

Endlocal

If there is a problem with batch processing, please check the settings of the environment variables, and note the settings of Embo_dex, the Xe5 installation path is reset (we can find the Classes.dex path in the previous release management), after successful batch processing, we can from the project directory \ Output\ Dex finds the classes.dex that contains our definition of SplashScreen

Re-entry to Delphi Release Management Project->deployment

Make sure that the default Classes.dex is not selected, click Add Files to select the Classes.dex generated by build, add the new item after successful addition, click Change Remote path

Include other resources in the release path as well

Res\layout\splash_activity.xml

Res\values\strings.xml

Res\drawable\splash.png

Click Save, next we want to modify the next Delphi Xe5 SplashScreen project configuration file

Open the AndroidManifest.template.xml profile template in the SplashScreen project directory and join the activity configuration item written by Java;

<activity android:name= "Com.cikk.splashsceen.SplashActivity"

android:screenorientation= "Portrait" >

<intent-filter>

<action android:name= "Android.intent.action.MAIN"/>

<category android:name= "Android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

<activity android:name= "Com.embarcadero.firemonkey.FMXNativeActivity" >

<intent-filter>

<action android:name= "Android.intent.action.MAIN"/>

<category android:name= "Android.intent.category.LAUNCHER"/>

</intent-filter>

Delete, the final my profile is as follows

<?xml version= "1.0" encoding= "Utf-8"?>

<!--begin_include (manifest)--

<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"

Package= "%package%"

Android:versioncode= "%versioncode%"

Android:versionname= "%versionname%" >

<!--the platform API where Nativeactivity was introduced. -

<USES-SDK android:minsdkversion= "%minsdkversion%"/>

<%uses-permission%>

<application android:persistent= "%persistent%"

android:restoreanyversion= "%restoreanyversion%"

Android:label= "%label%"

android:installlocation= "%installlocation%"

Android:debuggable= "? buggable%"

android:icon= "%icon%"

Android:theme= "%theme%" >

<activity android:name= "Com.cikk.splashsceen.SplashActivity"

android:screenorientation= "Portrait" >

<intent-filter>

<action android:name= "Android.intent.action.MAIN"/>

<category android:name= "Android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

<!--our activity is a subclass of the built-in Nativeactivity framework class.

This would take care of integrating and our NDK code. -

<activity android:name= "Com.embarcadero.firemonkey.FMXNativeActivity"

Android:label= "? tivitylabel%"

android:configchanges= "Orientation|keyboardhidden" >

<!--tell Nativeactivity the name of our---

<meta-data android:name= "Android.app.lib_name"

Android:value= "%libnamevalue%"/>

</activity>

<receiver android:name= "Com.embarcadero.firemonkey.notifications.FMXNotificationAlarm"/>

</application>

</manifest>

<!--end_include (manifest)--

Choose the debugging platform, debugging run it, because I am using the real machine debugging, so bad, I succeeded, you?

Finally, through these days to use the Delphi platform, feel that do traditional database applications, should be enough, but the related resources than Java is too scarce, if you want to call Java's three-party code is too cumbersome, such as the splash screen interface, rather than directly use Java development; We choose to develop a platform, we should consider !

Cikk

2013/12/4


Delphi XE5 for Android launch no black screen wait summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.