【问题标题】:Android.How to use other application data?Android.如何使用其他应用程序数据?
【发布时间】:2012-02-24 02:51:46
【问题描述】:

如何在 android 中使用来自另一个应用程序的数据到我的应用程序? 有什么办法可以从android中的其他应用程序访问数据?

【问题讨论】:

  • 请解释一下“数据”或您已经尝试过的内容。
  • 你能解释一下是哪种数据吗?
  • 您始终可以使用 startActivityForResult(developer.android.com/reference/android/app/…, int)) 作为结果,但是“其他应用程序”必须支持向您发送数据!
  • 如果您想将数据从一个应用程序使用到另一个应用程序,请将 application1 数据存储在文件中并从 application2 访问该文件。
  • 您可以使用共享文件夹中的文件。您可以使用套接字:stackoverflow.com/questions/7268320/…

标签: android


【解决方案1】:

你应该在应用程序之间阅读sending and receiving content,关于content providers,然后带着更好的问题回到这里。

【讨论】:

    【解决方案2】:

    在此示例中,使用 Intent 调用相机应用程序,获取 Bitmap 并在 ImageView 中设置。

    startCamera.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra("return-data", true);
            startActivityForResult(intent);
        }
    });
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
    
        if (resultCode == Activity.RESULT_OK) {
            Bitmap bitmap = (Bitmap) data.getExtras().get("data");
            imageView.setImageBitmap(bitmap);
            Toast.makeText(cameraActivity.this, "Saved", Toast.LENGTH_LONG).show();
        } else if (resultCode == Activity.RESULT_CANCELED) {
            Toast.makeText(getBaseContext(), "Camera cancelled by user", Toast.LENGTH_SHORT).show();
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2015-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-16
      • 1970-01-01
      • 1970-01-01
      • 2015-08-27
      相关资源
      最近更新 更多