質問編集履歴
1
文法の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -177,3 +177,131 @@
|
|
177
177
|
|
178
178
|
|
179
179
|
宜しくお願いします。
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
■ギャラリーから取得した場合
|
192
|
+
|
193
|
+
onActivityResult
|
194
|
+
|
195
|
+
```lang-java
|
196
|
+
|
197
|
+
try {
|
198
|
+
|
199
|
+
Uri uDataUri = intent.getData();
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
Bitmap bmp = BrandImage.getContentBitmapForUri(activity, uDataUri, Constants.iThumSizeW, Constants.iThumSizeH);
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
if (bmp == null) {
|
208
|
+
|
209
|
+
return;
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
String thumName = uDataUri.toString();
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
ImageView imgIdentification;
|
220
|
+
|
221
|
+
if (requestCode == ACTRES_PICKER) {
|
222
|
+
|
223
|
+
// パス名取得
|
224
|
+
|
225
|
+
sImagePath = common.getPath(me, uDataUri, requestCode);
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
imgIdentification = (ImageView) activity.findViewById(R.id.imgItem);
|
230
|
+
|
231
|
+
sImage = thumName;
|
232
|
+
|
233
|
+
bBitThum = bmp;
|
234
|
+
|
235
|
+
bImage = true;
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
imgIdentification.setImageBitmap(bmp);
|
242
|
+
|
243
|
+
} catch (Exception e) {
|
244
|
+
|
245
|
+
Toast.makeText(activity, "err Exception 3934", Toast.LENGTH_LONG).show();
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
```
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
common.getPath
|
254
|
+
|
255
|
+
```lang-java
|
256
|
+
|
257
|
+
public String getPath(Context context, Uri uri, Integer requestCode) {
|
258
|
+
|
259
|
+
Cursor cursor;
|
260
|
+
|
261
|
+
ContentResolver contentResolver = context.getContentResolver();
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
if (Build.VERSION.SDK_INT < 19) {
|
266
|
+
|
267
|
+
String[] columns = {
|
268
|
+
|
269
|
+
MediaStore.Images.Media.DATA
|
270
|
+
|
271
|
+
};
|
272
|
+
|
273
|
+
cursor = contentResolver.query(uri, columns, null, null, null);
|
274
|
+
|
275
|
+
} else {
|
276
|
+
|
277
|
+
String id = DocumentsContract.getDocumentId(uri);
|
278
|
+
|
279
|
+
String selection = "_id=?";
|
280
|
+
|
281
|
+
String[] selectionArgs = new String[]{id.split(":")[1]};
|
282
|
+
|
283
|
+
String[] columns = {
|
284
|
+
|
285
|
+
MediaStore.MediaColumns.DATA
|
286
|
+
|
287
|
+
};
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
cursor = contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, columns, selection, selectionArgs, null);
|
292
|
+
|
293
|
+
}
|
294
|
+
|
295
|
+
cursor.moveToFirst();
|
296
|
+
|
297
|
+
String path = cursor.getString(0);
|
298
|
+
|
299
|
+
cursor.close();
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
return path;
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
```
|