2017년 3월 11일 토요일

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.


1. Create an html page and install it on the web. (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=3번째 데이터">call Type2 한글</a><BR><BR>



2. Add the same intent-filter entry to the html page's uri entry in the AndroidManifest.template.xml file.



3. Create a Delphi Project.
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;



Demo Video

댓글 없음:

댓글 쓰기