在我的Fragment尝试从我的相机拍照,但onActivityResult我Fragment没有被调用.拍照后这Fragment没有显示,正在切换到我的第一个Fragment.在那里有任何其他方式来捕捉a中的照片Fragment,或者我做错了什么?
这是我目前的代码:
public void takePhoto() {
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
PhotosListFragment.this.startActivityForResult(intent, 100);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case 100:
if (resultCode == Activity.RESULT_OK) {
Uri selectedImage = imageUri;
getActivity().getContentResolver().notifyChange(selectedImage, null);
ContentResolver cr = getActivity().getContentResolver();
Bitmap bitmap;
try {
bitmap = android.provider.MediaStore.Images.Media
.getBitmap(cr, selectedImage);
viewHolder.imageView.setImageBitmap(bitmap); …Run Code Online (Sandbox Code Playgroud) 我的启动器活动意图有问题.Snenerio是:1.向我的启动器活动发送意图表单通知服务
PendingIntent contentIntent = PendingIntent.getActivity(this, TripLoggerConstants.PENDING_TRIPS_NOTIFICATION_ID, new Intent(this, MainActivity.class).putExtra("is_log", true), Intent.FLAG_ACTIVITY_CLEAR_TOP);
Run Code Online (Sandbox Code Playgroud)
2.在我的MainActivity中,我得到了这个意图.代码是:
if(this.getIntent().getExtras()!=null){
boolean isLogNewTripScreen = (boolean)this.getIntent().getExtras().getBoolean("is_log");
}
}
Run Code Online (Sandbox Code Playgroud)
3.这项工作正常,但是当我来自通知服务时,但是当我从非通知服务启动时,意图中的数据仍然存在.如何从意图中删除该数据.
我在水平滚动视图中添加了线性布局,并在布局中添加了一些文本视图.是否有可能在此布局中获得可见的孩子.
这段代码得到了所有孩子,但我想看到(仅显示)孩子:
final HorizontalScrollView scroll = (HorizontalScrollView)findViewById(R.id.horizontalScrollView1);
LinearLayout linearLayout = ((LinearLayout)scroll.findViewById(R.id.linearLayout1));
int chilrenNum = linearLayout.getChildCount();
Run Code Online (Sandbox Code Playgroud)