Android.How如何使用其他应用程序数据?

时间:2012-02-21 10:34:48

标签: android

如何在Android中将其他应用程序的数据用于我的应用程序? 有没有办法从Android中的其他应用程序访问数据?

2 个答案:

答案 0 :(得分:2)

您应该在应用程序之间阅读sending and receiving content,关于content providers并在此处返回更好的问题。

答案 1 :(得分:1)

在此示例中使用Intent调用Camera Application,获取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();
    }
}