Maher Tannous
-
Content Count
17 -
Joined
-
Last visited
Posts posted by Maher Tannous
-
-
I have a problem with phones running on Android 13 ( 64-bit ) I am using Delphi 11.3 and Android sdk with api 34 and MobilePermissions Component MobilePermissions The problem is that the storage permission does not work in Android 13 (64-bit), while it works on Android 11 and 12 (64-bit).
Any help please
-
3 hours ago, Dave Nottage said:Yes, this value can no longer be accessed by regular apps on Android since version 10.
It might help to know why you need this value
I want to protect my app with imei to be run on only one device
do you have another solution for running the app on one device only ?thx
-
I tried to get IMEI number and succeeded in all Android versions except 10-11-12-13in versions 10-11-12-13 the application not shown the main form
I am using Android sdk 26.1.1.32 with api level 33
and android-ndk-r21
and jdk-17.0.6.10
and the default jar libraries
and delphi 11.3
my code :
procedure Tmainform.FormShow(Sender: TObject); var tm: JTelephonyManager; IMEI: String; begin IMEI := ''; if MobilePermissions1.Dangerous.ReadPhoneState = false then Begin MobilePermissions1.Dangerous.ReadPhoneState := true; MobilePermissions1.Apply; End; tm := TJTelephonyManager.Create; IMEI := JStringtoString(tm.getImei); End;
-
Hello
I want an example for returning an array in datasnap server method
I tryed to make function to return an array in server side
but when generate client classes from client side delphi convert the array to string
any help ?
-
17 hours ago, Dave Nottage said:Actually putExtra takes a number of different types, including JParcelable. I've modified the Telecom import unit:
https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.Androidapi.JNI.Telecom.pas
So if you update that, it should now accept LAccountHandle
Thank you very much
this is my working code
1- Use this unit https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.Androidapi.JNI.Telecom.pas
2-
procedure CallByPhoneNumber(const PhoneNumber: string; SIMindex: Integer);
var
Intent: JIntent;
LService: JObject;
LAccounts: JList;
begin
LService := TAndroidHelper.Context.getSystemService
(TJContext.JavaClass.TELECOM_SERVICE);
Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_CALL);
Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
Intent.setData(TJnet_Uri.JavaClass.parse(StringToJString('tel:' +
JStringToString(TJnet_Uri.JavaClass.encode(StringToJString
(PhoneNumber))))));
Intent.putExtra(StringToJString('com.android.phone.force.slot'), true);
Intent.putExtra(StringToJString('Cdma_Supp'), true);
Intent.putExtra(StringToJString('extra_asus_dial_use_dualsim'), SIMindex);
Intent.putExtra(StringToJString('com.android.phone.extra.slot'), SIMindex);
Intent.putExtra(StringToJString('slot'), SIMindex);
Intent.putExtra(StringToJString('simslot'), SIMindex);
Intent.putExtra(StringToJString('sim_slot'), SIMindex);
Intent.putExtra(StringToJString('subscription'), SIMindex);
Intent.putExtra(StringToJString('Subscription'), SIMindex);
Intent.putExtra(StringToJString('phone'), SIMindex);
Intent.putExtra(StringToJString('com.android.phone.DialingMode'), SIMindex);
Intent.putExtra(StringToJString('simSlot'), SIMindex);
Intent.putExtra(StringToJString('slot_id'), SIMindex);
Intent.putExtra(StringToJString('simId'), SIMindex);
Intent.putExtra(StringToJString('simnum'), SIMindex);
Intent.putExtra(StringToJString('phone_type'), SIMindex);
Intent.putExtra(StringToJString('slotId'), SIMindex);
Intent.putExtra(StringToJString('slotIdx'), SIMindex);
Intent.putExtra(StringToJString('simSlotName'), SIMindex);
LAccounts := TJTelecomManager.Wrap(TAndroidHelper.JObjectToID(LService))
.getCallCapablePhoneAccounts;
if LAccounts <> nil then
Intent.putExtra
(StringToJString('android.telecom.extra.PHONE_ACCOUNT_HANDLE'),
TJPhoneAccountHandle.Wrap(TAndroidHelper.JObjectToID
(LAccounts.get(SIMindex))));
TAndroidHelper.Context.startActivity(Intent);
end;3-
CallByPhoneNumber(mobilenumber, 0);
or
CallByPhoneNumber(mobilenumber, 1);
- 2
-
22 hours ago, Dave Nottage said:That part should be more like this:
LAccounts := TJTelecomManager.Wrap(TAndroidHelper.JObjectToID(LService)).getCallCapablePhoneAccounts; if LAccounts <> nil then begin for I := 0 to 1 do begin if LAccounts.size > I then begin LPhoneAccountHandle := TJPhoneAccountHandle.Wrap(TAndroidHelper.JObjectToID(LAccounts.get(I))); Intent.putExtra(StringToJString('android.telecom.extra.PHONE_ACCOUNT_HANDLE'), LPhoneAccountHandle); end; end; end;
Intent.putExtra(StringToJString('android.telecom.extra.PHONE_ACCOUNT_HANDLE'), LPhoneAccountHandle);
does not accept
LPhoneAccountHandle
I must use JString or integer value
-
3 hours ago, Dave Nottage said:I've created a more compatible (with the other Delphi units) import for the Telecom classes, here:
https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.Androidapi.JNI.Telecom.pas
Which should at least make it a bit easier
Thank you
procedure CallByPhoneNumber(const PhoneNumber: string; SIMindex: Integer);
var
Intent: JIntent;
LService: JObject;
LAccounts: JList;
LPhoneAccountHandle: JPhoneAccountHandle;
I: Integer;
begin
LService := TAndroidHelper.Context.getSystemService
(TJContext.JavaClass.TELECOM_SERVICE);
Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_CALL);
Intent.setFlags(TJIntent.JavaClass.FLAG_ACTIVITY_NEW_TASK);
Intent.setData(TJnet_Uri.JavaClass.parse(StringToJString('tel:' +
JStringToString(TJnet_Uri.JavaClass.encode(StringToJString
(PhoneNumber))))));
Intent.putExtra(StringToJString('com.android.phone.force.slot'), true);
Intent.putExtra(StringToJString('Cdma_Supp'), true);
Intent.putExtra(StringToJString('extra_asus_dial_use_dualsim'), SIMindex);
Intent.putExtra(StringToJString('com.android.phone.extra.slot'), SIMindex);
Intent.putExtra(StringToJString('slot'), SIMindex);
Intent.putExtra(StringToJString('simslot'), SIMindex);
Intent.putExtra(StringToJString('sim_slot'), SIMindex);
Intent.putExtra(StringToJString('subscription'), SIMindex);
Intent.putExtra(StringToJString('Subscription'), SIMindex);
Intent.putExtra(StringToJString('phone'), SIMindex);
Intent.putExtra(StringToJString('com.android.phone.DialingMode'), SIMindex);
Intent.putExtra(StringToJString('simSlot'), SIMindex);
Intent.putExtra(StringToJString('slot_id'), SIMindex);
Intent.putExtra(StringToJString('simId'), SIMindex);
Intent.putExtra(StringToJString('simnum'), SIMindex);
Intent.putExtra(StringToJString('phone_type'), SIMindex);
Intent.putExtra(StringToJString('slotId'), SIMindex);
Intent.putExtra(StringToJString('slotIdx'), SIMindex);
LAccounts := TJTelecomManager.Wrap(TAndroidHelper.JObjectToID(LService))
.getCallCapablePhoneAccounts;
for I := 0 to LAccounts.size - 1 do
begin
LPhoneAccountHandle := TJPhoneAccountHandle.Wrap
(TAndroidHelper.JObjectToID(LAccounts.get(I)));
if (LAccounts <> null) AND (LAccounts.size() > 0) then
Begin
Intent.putExtra('Android.telecom.extra.PHONE_ACCOUNT_HANDLE',
LAccounts.get(0));
End
else if (LAccounts <> null) AND (LAccounts.size() > 1) then
Begin
Intent.putExtra('Android.telecom.extra.PHONE_ACCOUNT_HANDLE',
LAccounts.get(1));
End;
end;
TAndroidHelper.Context.startActivity(Intent);End;
I got an error here ( LAccounts.get(0) )
it returns an TJObject
but Intent.putExtra reqired a Byte
-
can any one make an example working project for me ?
thanks a lot
-
On 12/28/2019 at 3:15 AM, Dave Nottage said:There's an import for TelecomManager, here:
Be aware that Java2Pas (which was used for the import) sometimes puts instance methods where the class methods are, so they should be removed from there in the import.
getCallCapablePhoneAccounts is an instance method that returns a JList, containing instances of JPhoneAccountHandle, so one way to access them is to do this:
var LService: JObject; LAccounts: JList; LPhoneAccountHandle: JPhoneAccountHandle; I: Integer; begin Result := False; LService := TAndroidHelper.Context.getSystemService(TJContext.JavaClass.TELECOM_SERVICE); LAccounts := TJTelecomManager.Wrap(TAndroidHelper.JObjectToID(LService)).getCallCapablePhoneAccounts; for I := 0 to LAccounts.size - 1 do begin LPhoneAccountHandle := TJPhoneAccountHandle.Wrap(TAndroidHelper.JObjectToID(LAccounts.get(I))); // Do whatever with the LPhoneAccountHandle here end; end;
An import for PhoneAccountHandle is here:
Note that getCallCapablePhoneAccounts was introduced in API level 23.
Thank you
but
I have to put all files from this page
https://github.com/FMXExpress/android-object-pascal-wrapper/tree/master/android-28
in my project folder !!!
-
This to call TelecomManager
var
telService: JObject;telService := TAndroidHelper.Activity.getSystemService
(TJContext.JavaClass.TELECOM_SERVICE);But the problem is how to call : getCallCapablePhoneAccounts
-
-
30 minutes ago, Kas Ob. said:@Maher Tannous In my case it didn't ask to select between sims, and for the # it should be replaced with %23 so phone number should be:
have you tried to call from sim 2 ?
-
34 minutes ago, Dave Nottage said:Your code does not match the Java equivalent that has been sent to you. This is the equivalent:
uses Androidapi.JNI.GraphicsContentViewText, Androidapi.JNI.Net, Androidapi.Helpers; procedure TForm1.Button1Click(Sender: TObject); var MobileNumber: string; Intent: JIntent; begin MobileNumber := '*155#'; Intent := TJIntent.JavaClass.init(TJIntent.JavaClass.ACTION_CALL); Intent.putExtra(StringToJString('com.android.phone.extra.slot'), 1); Intent.putExtra(StringToJString('simSlot'), 1); Intent.setData(TJnet_Uri.JavaClass.parse(StringtoJString('tel:' + MobileNumber))); TAndroidHelper.Context.startActivity(Intent); end;
I don't have a dual SIM device to test this.
Those are not equivalent. TJIntent.JavaClass.EXTRA_PHONE_NUMBER is "android.intent.extra.PHONE_NUMBER", not "com.android.phone.extra.slot"
sorry for that but it does not work
your code is asking me to choose between sim card and if I choose sim 2
it calling the number *155
it does not run ussd code for *155#
it removes # and call *155
may be some one can test the code and tell me what happining
Thanks
-
hello
please i need help
i want to call a number from sim2 cardI want to request USSD code from sim2 slot without change any thing in android settings
any help to do that in delphi fmx androidsome one send me this
Intent intent = new Intent(Intent.ACTION_CALL);
intent.putExtra("com.android.phone.extra.slot", 1); //For sim 2
intent.putExtra("simSlot", 1); //For sim 2
intent.setData(Uri.parse("tel:" + "**********"));I tried this without success
I replaced "com.android.phone.extra.slot" with TJIntent.JavaClass.EXTRA_PHONE_NUMBER
but I can't find any thing to replace with "simSlot" ????My code :
uses
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNI.Net,
var
mobilenumber : string;
Intent : JIntent;
Begin
mobilenumber:='*155#';
Intent := TJIntent.Create;
Intent.setAction(TJIntent.JavaClass.ACTION_CALL); Intent.putExtra(TJIntent.JavaClass.EXTRA_PHONE_NUMBER, 1);
Intent.putExtra(TJIntent.JavaClass.EXTRA_INDEX, 1);
Intent.setData(TJnet_Uri.JavaClass.parse
(StringtoJString(mobilenumber)));
TAndroidHelper.Context.startActivity(Intent);
End; -
OK what is the best solution now ?
-
try this from github
https://github.com/Zeus64/alcinoe
I don't test it
this app https://play.google.com/store/apps/details?id=club.kiskis.app&hl=en was made with it
Android 13 ( 64-bit ) storage permission problem
in Cross-platform
Posted
I solved my problem with this code