我设法连接到彩信服务器并检索彩信数据。
现在我需要解析彩信数据(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();