开发者

How to call telepony and its sub class methods in Android activity class

开发者 https://www.devze.com 2023-03-09 10:50 出处:网络
How do I use non public classes in Android like telephony, android.telephony.CallManager in my Android application?
  1. How do I use non public classes in Android like telephony, android.telephony.CallManager in my Android application?
  2. How do I import this telephony packages in my开发者_JS百科 activity class and make it allow to access its functionality?


if you only need to call/send sms then you can use the Intent: call:

Intent i = new Intent(Intent.ACTION_CALL);
i.setData(Uri.parse("tel:" + phonenumber));
context.startActivity(i);

sms:

Intent i = new Intent(Intent.ACTION_VIEW);
i.setType("vnd.android-dir/mms-sms");
i.putExtra("sms_body", "message");
i.setData(Uri.parse("sms:" + phonenumber));
context.startActivity(i);

this was enough for me. if it isn't enough for you, you can use the TelephonyManager.

read more at here

as you can see, it is public. its just not initiate as new TelephonyManger(); but via getSystemService(TELEPHONY_SERVICE).

you can always use reflection if you will need some private class.

0

精彩评论

暂无评论...
验证码 换一张
取 消