当前位置:首页 » 安卓系统 » android图库

android图库

发布时间: 2022-01-22 08:43:52

⑴ Android 打开默认图库

开发的时候用Intent调用系统图库,不过如果手机装了多个图片浏览应用的话就会弹窗提示用户选择一个,这个时候要指定直接打开系统默认图库的话就要给Intent指定应用包,
Intent i = new Intent(
Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
i.setPackage("xxxx");// xxxx是具体报名,系统默认的一般是com.android.xx
startActivity(i);

// 同样的方式也适用与拍照,浏览网页等,包名具体自己查

⑵ 谁有根据Android原生系统Gallery图库为基础开发的demo

http://download.csdn.net/detail/geniusby/6254089#comment

⑶ Android开发,图库获取图片路径

public class TestCameraActivity extends Activity implements OnClickListener{ private Uri mOutPutFileUri; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button takePiCButton = (Button) this.findViewById(R.id.button1); takePiCButton.setOnClickListener(this); } @Override public void onClick(View v) { switch (v.getId()) { case R.id.button1: saveFullImage(); break; default: break; } } private void saveFullImage(){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //文件夹aaaa String path = Environment.getExternalStorageDirectory().toString()+"/aaaa"; File path1 = new File(path); if(!path1.exists()){ path1.mkdirs(); } File file = new File(path1,System.currentTimeMillis()+".jpg"); mOutPutFileUri = Uri.fromFile(file); intent.putExtra(MediaStore.EXTRA_OUTPUT, mOutPutFileUri); startActivityForResult(intent, 1); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == 1){ Uri imageUri = null; if(data != null){ if(data.hasExtra("data")){ Bitmap thunbnail = data.getParcelableExtra("data"); //处理缩略图 } }else{ //处理mOutPutFileUri中的完整图像 } } } }

⑷ 如何打开图库android gallery

Android原生内置了很多App,而Gallery为图库,用于操作设备上的图片,它会在开机的时候主动扫描设备上存储的图片,并可以使用Gallery操作它们。既然要使用Gallery,那么先看看它的AndroidManifest.xml清单文件。

<activity android:name="com.android.camera.ImageGallery"
android:label="@string/gallery_label"
android:configChanges="orientation|keyboardHidden"
android:icon="@drawable/ic_launcher_gallery">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/image" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/video" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.OPENABLE" />
<data android:mimeType="vnd.android.cursor.dir/image" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.OPENABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.dir/image" />
</intent-filter>
</activity>
上面是Gallery的AndroidManifest.xml文件中的部分代码,展示了ImageGallery,从众多Intent-filter中可以看出,选取图片应该使用"android.intent.action.PICK",它有两个miniType,"image/*"是用来获取图片的、"video/*"是用来获取视频的。Android中众多Action的字符串其实被封装在Intent类中,android.intent.action.PICK也不例外,它是Intent.ACTION_PICK。

既然知道了启动Gallery的Action,那么再看看ImageGallery.java源码,找找其中选中图片后的返回值。

private void launchCropperOrFinish(IImage img) {
Bundle myExtras = getIntent().getExtras();

long size = MenuHelper.getImageFileSize(img);
if (size < 0) {
// Return if the image file is not available.
return;
}

if (size > mVideoSizeLimit) {
DialogInterface.OnClickListener buttonListener =
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
};
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_info)
.setTitle(R.string.file_info_title)
.setMessage(R.string.video_exceed_mms_limit)
.setNeutralButton(R.string.details_ok, buttonListener)
.show();
return;
}

String cropValue = myExtras != null ? myExtras.getString("crop") : null;
if (cropValue != null) {
Bundle newExtras = new Bundle();
if (cropValue.equals("circle")) {
newExtras.putString("circleCrop", "true");
}

Intent cropIntent = new Intent();
cropIntent.setData(img.fullSizeImageUri());
cropIntent.setClass(this, CropImage.class);
cropIntent.putExtras(newExtras);

/* pass through any extras that were passed in */
cropIntent.putExtras(myExtras);
startActivityForResult(cropIntent, CROP_MSG);
} else {
Intent result = new Intent(null, img.fullSizeImageUri());
if (myExtras != null && myExtras.getBoolean("return-data")) {
// The size of a transaction should be below 100K.
Bitmap bitmap = img.fullSizeBitmap(
IImage.UNCONSTRAINED, 100 * 1024);
if (bitmap != null) {
result.putExtra("data", bitmap);
}
}
setResult(RESULT_OK, result);
finish();
}
}
以上的ImageGallery.java的部分源码,从setResult()方法可以看出,它返回的Intent包含了选中图片的Uri,它是一个content://开头的内容提供者,并且如果传递过去的Intent的Extra中,包含一个name为"return-data"并且值为true的时候,还会往Extra中写入name为"data"的图片缩略图。

⑸ android 怎样用 intent 打开自带的图库,就是说不用我找package name, 而

Intentontent=newIntent(Intent.ACTION_PICK,null);
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,"image/*");
startActivityForResult(ontent,REQUEST_ALBUM_OK);

这样就能打开相册了。

⑹ android调用系统图库的问题

调用系统图库:
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,"选择图片"), 2);

获取图片的内容:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Drawable d =null;
if (requestCode == 2) {
if (Activity.RESULT_OK == resultCode) {
Uri uri1 = data.getData();
Cursor cursor = this.getContentResolver().query(uri1, new String[]{"_data"},null, null, null);
if(cursor.moveToFirst()){
String otherfile = cursor.getString(0);
d=Drawable.createFromPath(otherfile );
}
}
}
}

⑺ android怎么调用系统自带的图库打开指定目录的相册

使用系统自带的图片浏览器应用程序Gallery可以打开一张指定的图片,
//使用Intent
Intent intent = new Intent(Intent.ACTION_VIEW);
//Uri mUri = Uri.parse("file://" + picFile.getPath());Android3.0以后最好不要通过该方法,存在一些小Bug
intent.setDataAndType(Uri.fromFile(picFile), "image/*");
startActivity(intent)

⑻ 如何强制刷新Android系统图库

系统自带的话,一般都是往下拉。如果没有,那就是不能刷新
不过我们可以投机取巧啊!你点一下设置→应用→找到图库(在全部应用里),强制关闭
之后你再打开就好了,系统崩溃就重启。或直接重启也行

⑼ 谁知道安卓图库的路径(截图的存放路径)

手机内部存储的Pictures/Screenshots/目录下

⑽ android开发,如何把图库中一张选中的照片,写入到APP的SQLite或者私有文件夹中

首先你能不能获取到图库中的图片,如果你已经获取了图库中的图片了,那么把图片放到数据库中的代码我给你,如果没有获取到图片,那你就先获取图片了再说咯

热点内容
途观21款哪个配置值得买 发布:2024-05-06 11:29:00 浏览:91
pythonspyder 发布:2024-05-06 11:15:53 浏览:165
线上服务器如何资源监控 发布:2024-05-06 11:15:07 浏览:298
页游脚本检测 发布:2024-05-06 11:05:05 浏览:924
七七网源码 发布:2024-05-06 10:27:36 浏览:295
shell输入脚本 发布:2024-05-06 10:19:49 浏览:985
通达信自定义板块在哪个文件夹 发布:2024-05-06 09:56:37 浏览:104
在linux搭建mqtt服务器搭建 发布:2024-05-06 09:52:00 浏览:559
windowspython23 发布:2024-05-06 09:27:50 浏览:748
编程ug开初 发布:2024-05-06 09:27:48 浏览:561