我设法连接到MMS服务器并检索MMS数据。
现在我需要解析MMS数据(byte [] responseArray)并获取像图像一样的数据。
有什么想法吗?
// Open connection
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// Disable cache
connection.setUseCaches(false);
// Set the timeouts
connection.setConnectTimeout(TIMEOUT);
connection.setReadTimeout(TIMEOUT);
// Connect to the MMSC
ensureRouteToHost(context, urlMms, apnSettings);
Log.d(TAG, "[MMS Receiver] Connecting to MMS Url " + urlMms);
connection.connect();
try
{
Log.d(TAG, "[MMS Receiver] Response code is " + connection.getResponseCode());
if (connection.getContentLength() >= 0)
{
Log.d(TAG, "[MMS Receiver] Download MMS data (Size: " + connection.getContentLength() + ")");
byte[] responseArray = new byte[connection.getContentLength()];
DataInputStream i = new DataInputStream(connection.getInputStream());
int b = 0;
int index = 0;
while ((b = i.read()) != -1)
{
responseArray[index] = (byte) b;
index++;
}
i.close();