【问题标题】:how can you share location same like whatsapp in android with chooser dialog?您如何使用选择器对话框共享与 Android 中的 whatsapp 相同的位置?
【发布时间】:2018-11-09 02:36:52
【问题描述】:

我希望 “共享位置” 功能与我当前应用程序中的 whatsapp 相同。

现在打开我使用下面提到的代码的选择器对话框。

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);
        }
    }

此代码选择器打开后类似于这样。

现在如何在此文件选择器对话框中添加共享位置图标,并在选择特定位置并在聊天应用程序中将其共享给其他用户后?

【问题讨论】:

  • 您可以尝试使用此编辑器进行位置共享github.com/irshuLx/Android-WYSIWYG-Editor 或者您可以使用底部对话框进行与whatsapp 相同的对话框
  • @VishvaDave 我不想从编辑那里得到它。我想从选择器对话框中打开它。选择一个位置后,它应该像我附加的最后一个屏幕截图一样显示。
  • 试试这个底部对话框 medium.com/glucosio-project/… 并在 recyclerview 项目中使用自定义布局作为地图类型......这将是一个广泛的答案,从某事开始,并在出现任何错误时返回

标签: android android-intent google-maps-api-3 whatsapp android-intent-chooser


【解决方案1】:

试试:

  1. 任何选择器都不具备所有类型的操作(即视频、位置、音频、文档等),每个选择器都基于一个类别。因此,对于这个选择器屏幕,请使用 Bottomsheet dialog。它与对话框相同,它将具有自定义布局。只需制作一个与屏幕相同的布局并在其中膨胀。
  2. 现在在点击位置的对话框中打开谷歌的 place picker。它看起来与您的位置选择器屏幕相同。
  3. 对于位置显示,请在 recyclerview 中使用自定义项目布局。即布局将具有线性布局(垂直)-> 图像视图和两个带有一些填充的文本视图。 Recyclerview demo

【讨论】:

猜你喜欢
  • 2019-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-15
  • 1970-01-01
  • 2016-01-12
  • 1970-01-01
相关资源
最近更新 更多