Android Question Convert java code to B4A

S.M.R

Member
Hi dears,
Can you convert beloew java code to b4a?


ChangeDefaultDialer:
#If java
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.app.role.RoleManager;
import android.os.Build;
import android.provider.Settings;
import anywheresoftware.b4a.BA;
import android.os.IBinder;

Context context=BA.applicationContext;
String packageName = context.getPackageName();

public void ChangeDefaultDialer()
{
    RoleManager roleManager = (RoleManager) getSystemService(ROLE_SERVICE);
    Intent intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_DIALER);
    startActivityForResult(intent, 1);
}
#End If

Thanks
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
In the Netherlands we have a proverb that reads: "Where the emperor is not, he loses his rights". The only way to access a specific dialer is using inline Java. In addition, it also dawns on Android designers that all kinds of things such as a dialer can be misused by malicious people.
Finally, in a similar question, Erel wrote this However, if you read the documentation you will see that it will not work on Android 10+ devices
I'm afraid that your and no direct B4A function is to use/misuse underlying dialer hardware and that you run into all kinds of security rules that you might be able to make work for a short time after deep research via some "hacks" or very heavy tweaking. Perhaps it is more convenient to ignore the dialer and look for another solution?
 
Upvote 0

S.M.R

Member
In the Netherlands we have a proverb that reads: "Where the emperor is not, he loses his rights". The only way to access a specific dialer is using inline Java. In addition, it also dawns on Android designers that all kinds of things such as a dialer can be misused by malicious people.
Finally, in a similar question, Erel wrote this However, if you read the documentation you will see that it will not work on Android 10+ devices
I'm afraid that your and no direct B4A function is to use/misuse underlying dialer hardware and that you run into all kinds of security rules that you might be able to make work for a short time after deep research via some "hacks" or very heavy tweaking. Perhaps it is more convenient to ignore the dialer and look for another solution?

this java code is working with inline java code and correct

but in some xiaomi device when run app is stopped and app crashed
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
Upvote 0
Top