외부 앱에 activity를 호출해서 응답받아야되는 개발건이 있어서 android 로 개발( 작동잘되는)된 샘플의 소스를 보고 소스를 작성하였는데 앱이 죽고 호출이 안되는 증상이 발생합니다.
ACTIVITY_SINGLE_TOP Flag로 내앱과 한몸인거처럼 호출하는게 관건인데요.
DEBUG모드호 해보면 SharedActivity.startActivityForResult(Intent,1); 까지 정상적으로 호출하면서 죽습니다.
메니페스트나 여러가지 소스에 설정을 바꿔바도 안되더군요
도움요청드립니다.
procedure TForm6.Button1Click(Sender: TObject);
var
Intent: JIntent;
PackageManager : JPackageManager;
ComponentName : JComponentName;
ResolveInfo : JResolveInfo;
stelegram : String;
begin
stelegram := '010101';
Intent := TJIntent.Create;
ComponentName := TJComponentName.Create;
try
ComponentName := TJComponentName.JavaClass.init( StringToJString('com.ksnet.kscat_a'), StringToJString('com.ksnet.kscat_a.PaymentIntentActivity') );
if ComponentName <> nil then
begin
Intent.SetAction( TJIntent.JavaClass.ACTION_MAIN );
Intent.SetFlags( TJIntent.JavaClass.FLAG_ACTIVITY_SINGLE_TOP or TJIntent.JavaClass.FLAG_ACTIVITY_CLEAR_TOP );
Intent.AddCategory( TJIntent.JavaClass.CATEGORY_LAUNCHER );
Intent.SetComponent( ComponentName );
if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then
begin
SharedActivity.startActivityForResult(Intent,1); <---- 호출하면 앱이 죽습니다.
end
else
memo1.Lines.Add('INTENT 0 호출실패');
end;
Except
on e: Exception do
begin
Memo1.Lines.Add( E.Message );
end;
end;
end;
===========================
아래는 안드로이드 소스입니다. ( 호출할 앱은 플레이스토어에 KSCAT_A 로 배포되어있습니다. )
// IC 승인요청
Button.OnClickListener btn1OnClickListener = new Button.OnClickListener(){
@Override
public void onClick(View v) {
EditText et = findViewById(R.id.spet1);
mDeviceNo = et.getText().toString();
makeTelegramIC("1");
// makeTelegramVANTR();
ComponentName componentName = new ComponentName("com.ksnet.kscat_a","com.ksnet.kscat_a.PaymentIntentActivity");
mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
mIntent.setComponent(componentName);
mIntent.putExtra("Telegram", mRequestTelegram);
mIntent.putExtra("TelegramLength", mRequestTelegram.length);
startActivityForResult(mIntent, 0);
<!-- 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="Project6"
android:configChanges="orientation"
android:launchMode="standard">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="Project6" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
질문
미루후예
안녕하세요
firemonkey 로 안드로이드 앱을 개발하는중입니다.
외부 앱에 activity를 호출해서 응답받아야되는 개발건이 있어서 android 로 개발( 작동잘되는)된 샘플의 소스를 보고 소스를 작성하였는데 앱이 죽고 호출이 안되는 증상이 발생합니다.
ACTIVITY_SINGLE_TOP Flag로 내앱과 한몸인거처럼 호출하는게 관건인데요.
DEBUG모드호 해보면 SharedActivity.startActivityForResult(Intent,1); 까지 정상적으로 호출하면서 죽습니다.
메니페스트나 여러가지 소스에 설정을 바꿔바도 안되더군요
도움요청드립니다.
procedure TForm6.Button1Click(Sender: TObject);
var
Intent: JIntent;
PackageManager : JPackageManager;
ComponentName : JComponentName;
ResolveInfo : JResolveInfo;
stelegram : String;
begin
stelegram := '010101';
Intent := TJIntent.Create;
ComponentName := TJComponentName.Create;
try
ComponentName := TJComponentName.JavaClass.init( StringToJString('com.ksnet.kscat_a'), StringToJString('com.ksnet.kscat_a.PaymentIntentActivity') );
if ComponentName <> nil then
begin
Intent.SetAction( TJIntent.JavaClass.ACTION_MAIN );
Intent.SetFlags( TJIntent.JavaClass.FLAG_ACTIVITY_SINGLE_TOP or TJIntent.JavaClass.FLAG_ACTIVITY_CLEAR_TOP );
Intent.AddCategory( TJIntent.JavaClass.CATEGORY_LAUNCHER );
Intent.SetComponent( ComponentName );
if MainActivity.getPackageManager.queryIntentActivities(Intent, TJPackageManager.JavaClass.MATCH_DEFAULT_ONLY).size > 0 then
begin
SharedActivity.startActivityForResult(Intent,1); <---- 호출하면 앱이 죽습니다.
end
else
memo1.Lines.Add('INTENT 0 호출실패');
end;
Except
on e: Exception do
begin
Memo1.Lines.Add( E.Message );
end;
end;
end;
===========================
아래는 안드로이드 소스입니다. ( 호출할 앱은 플레이스토어에 KSCAT_A 로 배포되어있습니다. )
// IC 승인요청
Button.OnClickListener btn1OnClickListener = new Button.OnClickListener(){
@Override
public void onClick(View v) {
EditText et = findViewById(R.id.spet1);
mDeviceNo = et.getText().toString();
makeTelegramIC("1");
// makeTelegramVANTR();
ComponentName componentName = new ComponentName("com.ksnet.kscat_a","com.ksnet.kscat_a.PaymentIntentActivity");
mIntent = new Intent(Intent.ACTION_MAIN);
mIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
mIntent.addCategory(Intent.CATEGORY_LAUNCHER);
mIntent.setComponent(componentName);
mIntent.putExtra("Telegram", mRequestTelegram);
mIntent.putExtra("TelegramLength", mRequestTelegram.length);
startActivityForResult(mIntent, 0);
TextView tv = findViewById(R.id.cardsvtv1);
String str = Util.HexDump.dumpHexString(mRequestTelegram);
tv.setText(str);
}
};
------------------------------------------------
메니페스트 - 별거 없어보입니다.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.exam.kscat_a_intentexam">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".CashActivity" android:label="cashActivity" android:configChanges="orientation" />
<activity android:name=".CardActivity" android:label="cardActivity" android:configChanges="orientation" />
<activity android:name=".ResultActivity" android:label="resultActivity" android:configChanges="orientation" />
<activity android:name=".ZeropayActivity" android:label="zeropayActivity" android:configChanges="orientation" />
<activity android:name=".KakaopayActivity" android:label="kakaopayActivity" android:configChanges="orientation" />
<activity android:name=".WeAlipayActivity" android:label="wealipayActivity" android:configChanges="orientation" />
<activity android:name=".LpayActivity" android:label="lpayActivity" android:configChanges="orientation" />
<activity android:name=".PrintTest" android:label="printTestActivity" android:configChanges="orientation" />
<activity android:name=".SubFuncActivity" android:label="subFuncActivity" android:configChanges="orientation" />
<activity android:name=".HDBPActivity" android:label="HDBPActivity" android:configChanges="orientation" />
<activity android:name=".BQActivity" android:label="BQActivity" android:configChanges="orientation" />
<activity android:name=".SPActivity" android:label="SPActivity" android:configChanges="orientation" />
<activity android:name=".Card2trActivity" android:label="2trActivity" android:configChanges="orientation" />
<activity android:name=".ViewTestActivity" android:label="TestActivity" android:configChanges="orientation" />
</application>
<uses-permission android:name="android.intent.action.MEDIA_MOUNTED" />
</manifest>
-------------------------------------
FMX 메니페스트 입니다.
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.embarcadero.Project6"
android:versionCode="1"
android:versionName="1.0.0"
android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="29" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<queries>
<package android:name="com.ksnet.kscat_a" />
<package android:name="com.ksnet.kscat_a.PaymentIntentActivity" />
</queries>
<uses-feature android:glEsVersion="0x00020000" android:required="True"/>
<application android:persistent="False"
android:restoreAnyVersion="False"
android:label="Project6"
android:debuggable="True"
android:largeHeap="true"
android:icon="@drawable/ic_launcher"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true"
android:requestLegacyExternalStorage="false">
<!-- 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="Project6"
android:configChanges="orientation"
android:launchMode="standard">
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name="android.app.lib_name"
android:value="Project6" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="com.embarcadero.rtl.notifications.NotificationAlarm" />
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
이 댓글 링크
다른 사이트에 공유하기
2 answers to this question
Recommended Posts
이 토의에 참여하세요
지금 바로 의견을 남길 수 있습니다. 그리고 나서 가입해도 됩니다. 이미 회원이라면, 지금 로그인하고 본인 계정으로 의견을 남기세요.