Micha Valach
Micha Valach

Reputation: 11

ClassCastException: com.android.internal.telephony.PhoneProxy

I'm newbie in Android.

I'm programing Instrumentation Tests for SIM ToolKit (STK)

I need to use CommandsInterface which is available only in PhoneBase Interface. Once I have a Phone i'd like to use the following line:

private Phone   mPhone;
private Context    mContext;
private Handler    mHandler;
private CommandsInterface            mCmdIf;
private PhoneBase    mPhoneBase;

mPhoneBase = ((PhoneBase)mPhone);  <==== uncaught exception 
mCmdIf = mPhoneBase.mCM;

It compiled successfully, however gives uncaught exception (group=0x4001b188) Please advice how to overcome this issue. Thanks In Advance Micha

Upvotes: 1

Views: 1047

Answers (1)

Macarse
Macarse

Reputation: 93143

You can't use PhoneBase directly because it's an internal in android and not visible in the SDK. You can check your exception msg using logcat.

From the source code:

/**
 * (<em>Not for SDK use</em>) 
 * A base implementation for the com.android.internal.telephony.Phone interface.
 * 
 * Note that implementations of Phone.java are expected to be used
 * from a single application thread. This should be the same thread that
 * originally called PhoneFactory to obtain the interface.
 *
 *  {@hide}
 *
 */

I don't know what mCM is, but I guess you can get that information from TelephonyManager. You can get it doing

Context.getSystemService(Context.TELEPHONY_SERVICE);

Upvotes: 2

Related Questions