티스토리 뷰

http://c2design5sh.blogspot.com/2017/03/calling-apps-from-web-with-android.html

 

Calling apps from the web with Android Intent

How to call the Delphi Firemonkey App from a web page via Android Intent. At this point, the URL parameter values are sent to the App. ...

c2design5sh.blogspot.com

안드로이드 인 텐트를 통해 WEB page에서 Delphi Firemonkey APP을 호출하는 방법.
이 시점에서 URL 매개 변수 값이 Delphi Firemonkey APP으로 전송됩니다.

 

1. html 페이지를 만들어 웹에 설치하십시오. (callapp.html)

<a href=" delphiapp://callType1?title=This is a Type1&data1=1111&data2=2222">call Type1</a><BR><BR> 
<a href=" delphiapp://callType2?title=This is a Type2&data1=3333&data2=4444&data3=5555">call Type2</a><BR><BR> 
<a href=" delphiapp://callType2?title=Type2 : 한글로로 된 제목&data1=6666&data2=7777&data3=2번째 데이터"> call Type2 한글</a><BR><BR>

2. AndroidManifest.template.xml 파일에서 HTML 페이지의 uri 항목에 동일한 의도 필터 항목 추가

<?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%">

    <!-- This is the platform API where NativeActivity was introduced. -->
    <uses-sdk android:minSdkVersion="%minSdkVersion%" android:targetSdkVersion="%targetSdkVersion%" />
<%uses-permission%>
    <application android:persistent="%persistent%"
        android:usesCleartextTraffic="true"
        android:restoreAnyVersion="%restoreAnyVersion%" 
        android:label="%label%" 
        android:installLocation="%installLocation%" 
        android:debuggable="%debuggable%" 
        android:largeHeap="%largeHeap%"
        android:icon="%icon%"
        android:theme="%theme%"
        android:hardwareAccelerated="%hardwareAccelerated%">
        <!-- Our activity is a subclass of the built-in NativeActivity framework class.
             This will take care of integrating with our NDK code. -->
        <activity android:name="com.embarcadero.firemonkey.FMXNativeActivity"
                android:label="%activityLabel%"
                android:configChanges="orientation|keyboardHidden"
                android:launchMode="singleTask">
            <!-- Tell NativeActivity the name of our .so -->
            <meta-data android:name="android.app.lib_name"
                android:value="%libNameValue%" />
            <intent-filter>  
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter> 
            <intent-filter>  
            	<action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                	android:host="callType1"
                    android:scheme="delphiapp" />
            </intent-filter> 
            <intent-filter>  
            	<action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />
                <data
                	android:host="callType2"
                    android:scheme="delphiapp" />
            </intent-filter>
        </activity>
        <%activity%>
        <receiver android:name="com.embarcadero.firemonkey.notifications.FMXNotificationAlarm" />
        <%receivers%>
    </application>
</manifest>
<!-- END_INCLUDE(manifest) -->

3. 델파이 프로젝트 생성

procedure TForm1.FormCreate(Sender: TObject);
{$IFDEF ANDROID}
var
  intent: JIntent;
  uri: Jnet_Uri;
  uriStr: String;
  rValue : TStringList;
  i : integer;
{$ENDIF}

begin
  {$IFDEF ANDROID}
  intent := SharedActivity.getIntent;
  if intent <> nil then
  begin
    if TJIntent.JavaClass.ACTION_VIEW.equals(intent.getAction) then
    begin
      uri := intent.getData;
      uriStr := JStringToString(uri.toString);  // read uriStr

      rValue := Get_URL_String( uriStr );  // parsing value

      for i := 0 to rValue.Count-1 do
         Memo1.Lines.Add( rValue[i] );
    end;
  end;
  {$ENDIF}
end;

https://www.youtube.com/watch?v=O1v0Gw-hvOA

 

댓글