如何使用选择器对话框共享与Android中的whatsapp相同的位置? [英] how can you share location same like whatsapp in android with chooser dialog?
本文介绍了如何使用选择器对话框共享与Android中的whatsapp相同的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要 共享位置" 功能与我当前应用程序中的 whatsapp 相同.
I want "share location" functionality same like whatsapp in my current application.
现在打开我使用下面提到的代码的选择器对话框.
Now to open chooser dialog i used below mentioned code.
public static void showFileChooser(Activity activity, Fragment fragment, boolean isAllowMultiple) {
try {
File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), "demo");
if (!imageStorageDir.exists()) {
imageStorageDir.mkdirs();
}
File file = new File(imageStorageDir + File.separator + "i" + String.valueOf(System.currentTimeMillis()) + ".jpg");
mCapturedImageURI = Uri.fromFile(file); // save to the private variable
final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
captureIntent.putExtra("capturedimageuri", mCapturedImageURI.toString());
// Intent for Audio Recording
final Intent audioRecordIntent = new Intent();
audioRecordIntent.setAction(IxxxConstants.ACTION_AUDIO_RECORD);
final Intent videoRecordIntent = new Intent();
videoRecordIntent.setAction(IxxxConstants.ACTION_VIDEO_RECORD);
// Use the GET_CONTENT intent from the utility class
Intent target = com.xxx.xxx.filechooser.FileUtils.createGetContentIntent();
if (isAllowMultiple) {
target.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}
// Create the chooser Intent
if (activity != null) {
Intent intent = Intent.createChooser(
target, activity.getString(R.string.chooser_title));
intent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{captureIntent, audioRecordIntent, videoRecordIntent});
activity.startActivityForResult(intent, IMAGE_ANNOTATION_REQUEST_CODE);
} else {
Intent intent = Intent.createChooser(
target, fragment.getString(R.string.chooser_title));
intent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{captureIntent, audioRecordIntent, videoRecordIntent});
fragment.startActivityForResult(intent, IMAGE_ANNOTATION_REQUEST_CODE);
}
} catch (ActivityNotFoundException e) {
xxxLog.e(DEBUG_TAG, "Error:" + e);
} catch (Exception ex) {
ex.printStackTrace();
CommonUtilities.showToast(activity, activity.getString(R.string.error_message), Toast.LENGTH_LONG);
}
}
在此代码选择器打开后,类似这样.
After this code chooser opens similar to like this.
现在如何在此位置选择器对话框中添加共享位置图标,并在选择特定位置并将其共享给聊天应用程序中的其他用户之后?
Now how can I add share location icon to this file chooser dialog and after selecting a particular location and share it to other user in chat application?
推荐答案
尝试:
- 任何选择者都没有每种类型的动作(即视频,位置,音频,文档等),每个选择器都基于一个类别.因此,对于此选择器屏幕,请使用 底部表对话框 .与对话框相同,它将具有自定义布局.只需使一种布局与屏幕相同,然后在其中进行充气即可.
- 点击位置"中的现在内部"对话框,打开 位置选择器 的Google.外观将与您的位置选择器屏幕相同.
- 要显示位置,请在recyclerview中使用自定义项目布局.即布局将具有线性布局(垂直)-> imageview和两个带有填充的textview. Recyclerview演示
这篇关于如何使用选择器对话框共享与Android中的whatsapp相同的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文