Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
String directory = Environment.getExternalStorageDirectory().toString() + "/" + storeLocation + "/";
String s = getBucketId(directory);
Uri target = Uri.parse("content://media/external/images/media?bucketId=" + s); 
Intent intent = new Intent(Intent.ACTION_VIEW, target);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);


if(Build.MODEL.contains("Nexus One")){
	Intent in = new Intent();
	in.setComponent(new ComponentName("com.cooliris.media","com.cooliris.media.Gallery"));
	in.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	
	// N1はbucketIdきかない
	startActivity(in);
	
}else{
	Boolean success = true;
	try{
		startActivity(intent);
	}catch(ActivityNotFoundException anf){
		Log.d(TAG, "onCreateOptionsMenu: cannot launch Gallery, trying to launch Hero specific Album");
		success = false;
	}
	
	if(!success){
		success = true;
		try{	
			// HTC端末の場合(Heroとか)
			Intent intent_heroAlbum = new Intent();
			intent_heroAlbum.setComponent(new ComponentName("com.htc.album","com.htc.album.AlbumTabSwitchActivity"));
			intent_heroAlbum.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent_heroAlbum); 
		}catch(ActivityNotFoundException anf){
			success = false;
			Toast.makeText(TakePictureMain.this, "failed to launch Gallery", Toast.LENGTH_SHORT).show();
		}
	}
	
}