當前位置: 首頁>>代碼示例>>Java>>正文


Java SmsManager.downloadMultimediaMessage方法代碼示例

本文整理匯總了Java中android.telephony.SmsManager.downloadMultimediaMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java SmsManager.downloadMultimediaMessage方法的具體用法?Java SmsManager.downloadMultimediaMessage怎麽用?Java SmsManager.downloadMultimediaMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.telephony.SmsManager的用法示例。


在下文中一共展示了SmsManager.downloadMultimediaMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: retrieve

import android.telephony.SmsManager; //導入方法依賴的package包/類
@Override
@TargetApi(VERSION_CODES.LOLLIPOP)
public synchronized @Nullable RetrieveConf retrieve(@NonNull String contentLocation,
                                                    byte[] transactionId,
                                                    int subscriptionId) throws MmsException
{
  beginTransaction();

  try {
    MmsBodyProvider.Pointer pointer = MmsBodyProvider.makeTemporaryPointer(getContext());

    Log.w(TAG, "downloading multimedia from " + contentLocation + " to " + pointer.getUri());

    SmsManager smsManager;

    if (VERSION.SDK_INT >= 22 && subscriptionId != -1) {
      smsManager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId);
    } else {
      smsManager = SmsManager.getDefault();
    }

    smsManager.downloadMultimediaMessage(getContext(),
                                         contentLocation,
                                         pointer.getUri(),
                                         null,
                                         getPendingIntent());

    waitForResult();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Util.copy(pointer.getInputStream(), baos);
    pointer.close();

    Log.w(TAG, baos.size() + "-byte response: " + Hex.dump(baos.toByteArray()));

    return (RetrieveConf) new PduParser(baos.toByteArray()).parse();
  } catch (IOException | TimeoutException e) {
    Log.w(TAG, e);
    throw new MmsException(e);
  } finally {
    endTransaction();
  }
}
 
開發者ID:XecureIT,項目名稱:PeSanKita-android,代碼行數:44,代碼來源:IncomingLollipopMmsConnection.java

示例2: retrieve

import android.telephony.SmsManager; //導入方法依賴的package包/類
@Override
@TargetApi(VERSION_CODES.LOLLIPOP)
public synchronized @Nullable RetrieveConf retrieve(@NonNull String contentLocation,
                                                    byte[] transactionId,
                                                    int subscriptionId) throws MmsException
{
  beginTransaction();

  try {
    MmsBodyProvider.Pointer pointer = MmsBodyProvider.makeTemporaryPointer(getContext());

    Log.w(TAG, "downloading multimedia from " + contentLocation + " to " + pointer.getUri());

    SmsManager smsManager;

    if (VERSION.SDK_INT >= 22 && subscriptionId != -1) {
      smsManager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId);
    } else {
      smsManager = SmsManager.getDefault();
    }

    smsManager.downloadMultimediaMessage(getContext(),
                                         contentLocation,
                                         pointer.getUri(),
                                         null,
                                         getPendingIntent());

    waitForResult();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Util.copy(pointer.getInputStream(), baos);
    pointer.close();

    Log.w(TAG, baos.size() + "-byte response: ");// + Hex.dump(baos.toByteArray()));

    return (RetrieveConf) new PduParser(baos.toByteArray()).parse();
  } catch (IOException | TimeoutException e) {
    Log.w(TAG, e);
    throw new MmsException(e);
  } finally {
    endTransaction();
  }
}
 
開發者ID:CableIM,項目名稱:Cable-Android,代碼行數:44,代碼來源:IncomingLollipopMmsConnection.java

示例3: retrieve

import android.telephony.SmsManager; //導入方法依賴的package包/類
@Override
@TargetApi(VERSION_CODES.LOLLIPOP)
public synchronized @Nullable RetrieveConf retrieve(@NonNull String contentLocation,
                                                    byte[] transactionId,
                                                    int subscriptionId) throws MmsException
{
  beginTransaction();

  try {
    MmsBodyProvider.Pointer pointer = MmsBodyProvider.makeTemporaryPointer(getContext());

    Log.w(TAG, "downloading multimedia from " + contentLocation + " to " + pointer.getUri());

    SmsManager smsManager;

    if (VERSION.SDK_INT >= 22 && subscriptionId != -1) {
      smsManager = SmsManager.getSmsManagerForSubscriptionId(subscriptionId);
    } else {
      smsManager = SmsManager.getDefault();
    }

    smsManager.downloadMultimediaMessage(getContext(),
                                         contentLocation,
                                         pointer.getUri(),
                                         null,
                                         getPendingIntent());

    waitForResult();

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Util.copy(pointer.getInputStream(), baos);
    pointer.close();

    return (RetrieveConf) new PduParser(baos.toByteArray()).parse();
  } catch (IOException | TimeoutException e) {
    Log.w(TAG, e);
    throw new MmsException(e);
  } finally {
    endTransaction();
  }
}
 
開發者ID:SilenceIM,項目名稱:Silence,代碼行數:42,代碼來源:IncomingLollipopMmsConnection.java


注:本文中的android.telephony.SmsManager.downloadMultimediaMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。