本文整理汇总了Java中android.support.v4.os.ResultReceiver.send方法的典型用法代码示例。如果您正苦于以下问题:Java ResultReceiver.send方法的具体用法?Java ResultReceiver.send怎么用?Java ResultReceiver.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.os.ResultReceiver
的用法示例。
在下文中一共展示了ResultReceiver.send方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performLoadItem
import android.support.v4.os.ResultReceiver; //导入方法依赖的package包/类
private void performLoadItem(String itemId, final ResultReceiver receiver) {
Result<MediaItem> result = new Result<MediaItem>(itemId) {
void onResultSent(MediaItem item, int flag) {
Bundle bundle = new Bundle();
bundle.putParcelable(MediaBrowserServiceCompat.KEY_MEDIA_ITEM, item);
receiver.send(0, bundle);
}
};
onLoadItem(itemId, result);
if (!result.isDone()) {
throw new IllegalStateException("onLoadItem must call detach() or sendResult() before returning for id=" + itemId);
}
}
示例2: publishProgress
import android.support.v4.os.ResultReceiver; //导入方法依赖的package包/类
/**
* publish progress to main thread to update progress UI.
*
* @param progress - percent value out of 100.
*/
private void publishProgress(ResultReceiver receiver, int progress)
{
if (receiver != null)
{
Bundle bundle = new Bundle();
bundle.putInt(RESPONSE_DOWNLOAD_PROGRESS, progress);
//bundle.putString(RESPONSE_TYPE,extension);
receiver.send(RESPONSE_CODE_DOWNLOAD_PROGRESS, bundle);
}
}
示例3: onHandleIntent
import android.support.v4.os.ResultReceiver; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent)
{
mContext = getApplicationContext();
dbcon = new DBController(mContext);
instaImage = new InstaImage();
stopDownload = false;
String fileUrl = intent.getStringExtra(ARGUMENT_FILE_URL);
instaImage.set_instaImageURL(fileUrl);
//String targetFile = intent.getStringExtra(ARGUMENT_TARGET_FILE);
ResultReceiver receiver = intent.getParcelableExtra(ARGUMENT_RESUTL_RECIEVER);
String contentType = openConnection(fileUrl);
String outputFilePath = null;
String targetFile="";
String fileName="";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd-hh-mm-ss");
File direct = new File(Environment.getExternalStorageDirectory() + "/InstantInsta");
File file=null;
if (!direct.exists()) {
direct = new File(Environment.getExternalStorageDirectory() + "/InstantInsta");
direct.mkdirs();
}
if (contentType == null)
{
outputFilePath = null;
} else if (contentType.contains("image")) {
fileName = "Insta-" + simpleDateFormat.format(new Date()) + ".jpg";
file = new File(direct, fileName);
if (file.exists()) {
file.delete();
// some code to stop duplication
}
instaImage.set_name(fileName);
outputFilePath = downloadImage(file.getAbsolutePath());
//extension = "jpg";
} else {
fileName = "Insta-" + simpleDateFormat.format(new Date()) + ".mp4";
file = new File(direct, fileName);
if (file.exists()) {
file.delete();
// some code to stop duplication
}
instaImage.set_name(fileName);
outputFilePath = downloadFile(file.getAbsolutePath(), receiver);
//extension = "mp4";
}
Bundle bundle = new Bundle();
bundle.putString(RESPONSE_TARGET_FILE, outputFilePath);
bundle.putString(RESPONSE_CAPTION, instaImage.get_caption());
receiver.send(RESPONSE_CODE_DOWNLOAD_RESULT, bundle);
}