Answer the question
In order to leave comments, you need to log in
How to correctly include the com.android.internel.telephone package and import ITelephony into Android Studio?
Greetings.
I need help in the following situation:
Situation:
in Andriod Studio I am writing code in BroadcastReceiver to programmatically reset an incoming call, I looked at a bunch of code options on the Internet, in all examples there is a use of com.android.internel.telephone.ITelephony, which can only be accessed through the interface Telephony - also rummaged through a bunch of information on installing the com.android.internel.telephone package itself and importing ITelephony - nothing happens. When creating a package com.android.internel.telephone in the java folder, the package being created is "cut" into com and the android.internel.telephone nested in it - should it be so? When creating an interface, ITelephony is also something incomprehensible, there are examples where ITelephony is added as Class java, in others - as ITelephony.aidl - which is correct?
Question:
can someone write down the points where what and how to do, so that in the end you get the correct working result?
Thank you.
PS
1. I tried again adding the com.android.internel.telephone package and importing ITelephony. When creating the package, despite the fact that I added it to the java folder, I still got the structure: app->java->com->android.internel.telephone. Further, when interface ITelephony.aidl was added to android.internel.telephone, the structure changed again: app->java->com->android.internel.telephone - it remained the same, the interface ITelephony.aidl file was not added, but a new structure appeared :
app->aidl->com.android.internel.telephone->ITelephony.aidl - Android Studio ( 3.4 ) does everything right?
2. In ITelephony.
package com.android.internal.telephony;
interface ITelephony {
boolean endCall();
void answerRingingCall();
void silenceRinger();
}
...
import com.android.internal.telephony.ITelephony;
...
public class CallingReceiver extends BroadcastReceiver {
...
}
public void disconnectPhoneItelephony( Context context ){
ITelephony telephonyService;
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
try {
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony) m.invoke(tm);
telephonyService.endCall();
} catch (Exception e) {
e.printStackTrace();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question