本文整理汇总了Java中com.hyphenate.chat.EMFileMessageBody.getLocalUrl方法的典型用法代码示例。如果您正苦于以下问题:Java EMFileMessageBody.getLocalUrl方法的具体用法?Java EMFileMessageBody.getLocalUrl怎么用?Java EMFileMessageBody.getLocalUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hyphenate.chat.EMFileMessageBody
的用法示例。
在下文中一共展示了EMFileMessageBody.getLocalUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.hyphenate.chat.EMFileMessageBody; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ease_activity_show_file);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
final EMFileMessageBody messageBody = getIntent().getParcelableExtra("msgbody");
file = new File(messageBody.getLocalUrl());
//set head map
final Map<String, String> maps = new HashMap<String, String>();
if (!TextUtils.isEmpty(messageBody.getSecret())) {
maps.put("share-secret", messageBody.getSecret());
}
//下载文件
EMClient.getInstance().chatManager().downloadFile(messageBody.getRemoteUrl(), messageBody.getLocalUrl(), maps,
new EMCallBack() {
@Override
public void onSuccess() {
runOnUiThread(new Runnable() {
public void run() {
FileUtils.openFile(file, EaseShowNormalFileActivity.this);
finish();
}
});
}
@Override
public void onProgress(final int progress,String status) {
runOnUiThread(new Runnable() {
public void run() {
progressBar.setProgress(progress);
}
});
}
@Override
public void onError(int error, final String msg) {
runOnUiThread(new Runnable() {
public void run() {
if(file != null && file.exists()&&file.isFile())
file.delete();
String str4 = getResources().getString(R.string.Failed_to_download_file);
Toast.makeText(EaseShowNormalFileActivity.this, str4+msg, Toast.LENGTH_SHORT).show();
finish();
}
});
}
});
}
示例2: onCreate
import com.hyphenate.chat.EMFileMessageBody; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ease_activity_show_file);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
final EMFileMessageBody messageBody = getIntent().getParcelableExtra("msgbody");
file = new File(messageBody.getLocalUrl());
//set head map
final Map<String, String> maps = new HashMap<String, String>();
if (!TextUtils.isEmpty(messageBody.getSecret())) {
maps.put("share-secret", messageBody.getSecret());
}
//download file
EMClient.getInstance().chatManager().downloadFile(messageBody.getRemoteUrl(), messageBody.getLocalUrl(), maps,
new EMCallBack() {
@Override
public void onSuccess() {
runOnUiThread(new Runnable() {
public void run() {
FileUtils.openFile(file, EaseShowNormalFileActivity.this);
finish();
}
});
}
@Override
public void onProgress(final int progress,String status) {
runOnUiThread(new Runnable() {
public void run() {
progressBar.setProgress(progress);
}
});
}
@Override
public void onError(int error, final String msg) {
runOnUiThread(new Runnable() {
public void run() {
if(file != null && file.exists()&&file.isFile())
file.delete();
String str4 = getResources().getString(R.string.Failed_to_download_file);
Toast.makeText(EaseShowNormalFileActivity.this, str4+msg, Toast.LENGTH_SHORT).show();
finish();
}
});
}
});
}