當前位置:首頁 » 安卓系統 » 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或者私有文件夾中

首先你能不能獲取到圖庫中的圖片,如果你已經獲取了圖庫中的圖片了,那麼把圖片放到資料庫中的代碼我給你,如果沒有獲取到圖片,那你就先獲取圖片了再說咯

熱點內容
英雄聯盟和飢荒哪個配置要求更高 發布:2024-04-24 07:55:09 瀏覽:603
linuxcpu佔用進程 發布:2024-04-24 07:37:05 瀏覽:119
河南移動鶴壁dns伺服器地址 發布:2024-04-24 07:36:58 瀏覽:592
百度賬號密碼怎麼設置密碼 發布:2024-04-24 07:27:37 瀏覽:759
cf窗口化源碼 發布:2024-04-24 07:04:33 瀏覽:738
linuxi2c設備 發布:2024-04-24 06:53:50 瀏覽:346
寶馬x5買什麼配置性價比高 發布:2024-04-24 06:45:22 瀏覽:850
最小的編程語言 發布:2024-04-24 06:44:16 瀏覽:817
自動發朋友圈腳本 發布:2024-04-24 06:40:32 瀏覽:154
最早存儲盤 發布:2024-04-24 06:39:54 瀏覽:944