I used SmsCbMessage.java class in a my program. It was taken from http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/telep
It is probable that Huawei has customized the SmsCbMessage
class. What you can do is to use reflection to see what methods are available on that class and hope that one looks like the one you need. Try something like this:
try {
Class clazz = Class.forName("android.telephony.SmsCbMessage");
Method[] methods = clazz.getDeclaredMethods();
for (Method m : methods) {
Log.v("XXX", "Method found: " + m);
}
} catch (Exception e) {
Log.e("XXX", "Exception: " + e);
}
if you look at the sourcecode of SmsCbMessage@android.googlesource.com
you will see that the class is marked with the "@hide" attribute
/*
* ....
* @hide
*/
public class SmsCbMessage implements Parcelable {...
This means that the class is an implementation detail of android that is not part of the public android api and that can be changed or removed without notice.
SmsCbMessage@android.googlesource.com does hot have the method public static SmsCbMessage createFromPdu(byte[] pdu)
while your codefragment does have it.
Your Test-Device does have this class but without the static method.
If you want to use the class anyway you can add the sourcecode to your project and rename the package
[Update 2015-06-25]
Since adding source from grepcodes to local project does not solve the problem because it has to many dependencies (especially android.internal.*)
you can create your own MySmsCbMessage that inherits from devices SmsCbMessage class and try to add missing functions from grepcodes source.
public class MySmsCbMessage extends SmsCbMessage {
public static SmsCbMessage createFromPdu(byte[] pdu) {
try {
return new MySmsCbMessage(pdu);
} catch (IllegalArgumentException e) {
Log.w(LOG_TAG, "Failed parsing SMS-CB pdu", e);
return null;
}
}
}
This is still a fragile workaround because you cannot be shure that other devices will have SmsCbMessage