如何访问com.android.internal.telephony.gsm.GsmSmsDispatcher实例? [英] How to access com.android.internal.telephony.gsm.GsmSmsDispatcher instance?

查看:125
本文介绍了如何访问com.android.internal.telephony.gsm.GsmSmsDispatcher实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要访问com.android.internal.telephony.gsm.GsmSmsDispatcher的 sendRawPdu 方式。

I need to access com.android.internal.telephony.gsm.GsmSmsDispatcher's sendRawPdu method.

我已经做了一些调查,发现的 GSMPhone 的类中包含的 GsmSmsDispatcher 的实例。我希望获得的 GSMPhone 的情况下从的 PhoneFactory 的,但它似乎是未初始化(它是静态变量的的)。

I've done a little research and found that GSMPhone class contains GsmSmsDispatcher instance. I hoped to obtain GSMPhone instance from PhoneFactory but it seems to be uninitialized (it's static variables are null).

Android的API版本> = 8。

Android API version >= 8.

推荐答案

使用反射,你不能访问Android的内部类。在Android的每个应用程序在自己的进程有自己的Dalvik虚拟机实例中运行。类在一个进程中加载​​是不可见的另一个进程。所以,当您尝试从PhoneFactory访问静态变量,你最终加载PhoneFactory类的 unintialized变量的。

You can't access Android's internal classes using reflection. Each application in Android runs in its own process with its own instance of the Dalvik VM. Classes loaded in one process are not visible to another process. So when you try to access static variables from PhoneFactory, you end up loading the PhoneFactory class with unintialized variables.

您最好的将是做任何你想要使用Android API来完成的获得。有几种方法来获得访问一些私人的Andr​​oid服务,但不会让你太过分了。唯一有关的一个短信是在主义服务。你可以看一下穿过ISms.aidl文件present在com.android.internal.telephony包中可使用的方法。

Your best will be to do whatever you want to get done using the Android APIs. There are a few ways to get access to some private Android services, but it won't get you too far. The only relevant one for SMS is the isms service. You can look through the methods available in it in the ISms.aidl file present in the com.android.internal.telephony package.

这篇关于如何访问com.android.internal.telephony.gsm.GsmSmsDispatcher实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆