I am newbie to native android development. I am working on android studio
and developing an app with 3 tabs. 1 for map, 2nd is for camera and third is for displaying pictures that are taken in 2nd tab from camera. For this i saw many tutorials. But unfortunately i am unable to get any help from them. I have separate classes
and layout
for each of the tabs
. I am able to save images into my sdcard
.
Below is my code for camera
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.camera, container, false);
button = (Button)rootView.findViewById(R.id.getpicture);
imageView = (ImageView)rootView.findViewById(R.id.imageView);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Check permission for CAMERA
if (ActivityCompat.checkSelfPermission(getActivity(), CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
// Check Permissions Now
// Callback onRequestPermissionsResult interceptado na Activity MainActivity
ActivityCompat.requestPermissions(getActivity(),
new String[]{CAMERA},
Camera.REQUEST_CAMERA);
}
else {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE );
}
}
});
return rootView;
}
Method to save images
private void SaveImage(Bitmap finalBitmap) {
String root = Environment.getExternalStorageDirectory().getAbsolutePath().toString();
Log.v(getTag(), root);
File myDir = new File(root + "/saved_images");
myDir.mkdirs();
Random generator = new Random();
int n = 10000;
n = generator.nextInt(n);
String fname = "Image-" + n + ".jpg";
File file = new File(myDir,fname);
if (file.exists())file.delete();
try {
FileOutputStream out = new FileOutputStream(file);
finalBitmap.compress(Bitmap.CompressFormat.JPEG,90,out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
//Toast.makeText(getContext(), "Image is saved", Toast.LENGTH_LONG).show();
}
Below is my Pictures
tab class in which i want to show my images on slider
public class Pictures extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.pictures, container, false);
return rootView;
}}
Note:
I need a image slider to show images saved in my sd card folder.
I am stuck to it almost a day and i am getting fed-up from it and i need help.
Any help will be highly appreciated.